How can i plot a term of a function divided by the previous term of said function?
Show older comments
Lets say i have a file wrote which gives me the outputs of a given series. (e.g. 7x^2+x)
How do i plot x(n+1)/x(n)?
Im looking for a way to do that for all the values of say n=1 to n=25.
Answers (1)
dpb
on 12 Feb 2014
yrat=y(2:end)./y(1:end-1);
plot(x(2:end,yrat)
the choice of which x to use for the abscissa is somewhat arbitrary, maybe you'll want to use xrat instead of an absolute x
6 Comments
Robert Long
on 12 Feb 2014
Iain
on 12 Feb 2014
x = 1:26;
series = 7*x.^2 + x;
plot(x(1:end-1), series(1:end-1).\series(2:end))
Robert Long
on 12 Feb 2014
dpb
on 12 Feb 2014
plot(x(2:end,yrat)
Clearly there's a typo -- the unbalanced paren's shouldn't be hard to spot.
plot(x(2:end),yrat)
Just add the ':' for the row index to refer to all elements of each column.
R(2:end,:)./R(1:end-1,:)
Need to read up on "Getting Started" documentation on the colon operator and general Matlab syntax for addressing arrays and work thru the examples some.
Robert Long
on 12 Feb 2014
Me no follow...what are the "first element/2nd element, 2nd element/3rd element" specifically referring to?
And, specifically, what is the 1x1 reference to? You mean you want a scatter plot instead of a line plot, or are you looking at animation of adding a point at a time or what?
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!