My Math Forum  

Go Back   My Math Forum > Math Forums > Math Software

Math Software Math Software - Mathematica, Matlab, Calculators, Graphing Software


Reply
 
LinkBack Thread Tools Display Modes
December 3rd, 2018, 07:06 PM   #1
Newbie
 
Joined: Oct 2018
From: Turkey

Posts: 23
Thanks: 0

matlab plotting and defining range

I have the function in Matlab:

y=(2*cos(x)^2-1)/cos(x)

All i want is a simple plot of this. i want x to be from -pi to pi for example

so i wrote
x = -pi : pi

But when i said plot (x,y)

Matlab says:

"Error using plot
Data must be numeric, datetime, duration or an array convertible to double"

Where am i making a mistake?
ketanco is offline  
 
December 6th, 2018, 03:01 PM   #2
Senior Member
 
Joined: Feb 2016
From: Australia

Posts: 1,739
Thanks: 609

Math Focus: Yet to find out.
If you want a numeric plot, you’d need to pass x into y first to create a vector. Alternatively you can set x to be symbolic (syms x) and then use fplot(y).
Joppy is offline  
Reply

  My Math Forum > Math Forums > Math Software

Tags
defining, matlab, plotting, range



Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
need help in defining a function janeryk Trigonometry 1 April 25th, 2016 05:15 AM
Need help defining a function willeb96 Algebra 9 July 20th, 2014 02:27 PM
Defining functions Mr Davis 97 Calculus 1 May 11th, 2014 06:51 PM
Plotting simple sound source Matlab jellicorse Math Software 0 March 24th, 2014 02:27 PM
Calculating a position in a range while limiting the range tale Computer Science 5 May 23rd, 2012 06:16 AM





Copyright © 2018 My Math Forum. All rights reserved.