How can I plot an equation in the form y=mx+c

6 views (last 30 days)
HI2
HI2 on 28 Nov 2015
Commented: Star Strider on 28 Nov 2015
I want to plot an equation where t1=p*t2+g , i have already defined what p and g are and both t1 and t2 are vectors of size 8x1, i tried ezplot('p*t2+g') but i get errors including saying t2 isn't defined, something about inline/feval and other malarkey. tbh im new to matlab so any help wouldn't go amiss, thanks.

Answers (2)

Star Strider
Star Strider on 28 Nov 2015
If you already have ‘t1’ and ‘t2’, you can plot them directly:
figure(1)
plot(t2, t1)
grid
  7 Comments
HI2
HI2 on 28 Nov 2015
ezplot('p*T2b+g') I am at this point and I have sorted every other problem except now that it says it cannot plot this in the x,y plane
Star Strider
Star Strider on 28 Nov 2015
You have to present it to ezplot as an ‘anonymous function’ as I did (see the documentation for ezplot for details), along with correct values of ‘p’ and ‘g’ and the correct range of values (minimum and maximum) for ‘T2a’.

Sign in to comment.


Image Analyst
Image Analyst on 28 Nov 2015
You know that MATLAB is case sensitive, don't you? T2 is different than t2. You have to use the same capitalization if you want them to be the same variable.
I never use ezplot() - I just define t2 so I know what it will be rather than trust that function to select a range that I may or may not be happy with.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!