Is there a command to match isolated points on graph by a curve, not straight lines?

1 view (last 30 days)
teta=[0.25,0.5,0.75,1,1.25]
eta100=100-1/1*(1.5./teta+teta*2.2)
plot(teta, eta100,'k','LineWidth',2) %some line specification for curved plot?

Accepted Answer

Star Strider
Star Strider on 25 Oct 2014
Edited: Star Strider on 25 Oct 2014
Something like this?
Example using 'spline' interpolation:
teta=[0.25,0.5,0.75,1,1.25]
eta100=100-1/1*(1.5./teta+teta*2.2)
tetai = linspace(min(teta), max(teta)); % Create Interpolation Points
eta100i = interp1(teta, eta100, tetai,'spline'); % Use 'spline' Interpolation
plot(tetai, eta100i,'k','LineWidth',2) %some line specification for curved plot?
hold on
plot(teta,eta100,'*r')
hold off
legend('Interpolated Line','Data', 'Location','SE')
EDIT — Added plot:
  2 Comments
Daniel
Daniel on 25 Oct 2014
Yes, this is it, I was just wondering whether it is possible to do automatic interpolation as an option somewhere in plot command (like in Excel) without creating any additional variable
Star Strider
Star Strider on 25 Oct 2014
My pleasure!
That’s about as efficient as it gets in MATLAB. Defining the interpolation vector (here ‘tetai’) and then doing the interpolation and plotting it is necessary. It is certainly possible to write a function to do what you want, essentially incorporating all the steps I did here, depending on what you want it to do. That would do everything in one command. We can work on that if you like.
Back in a few minutes. Windows decided to force me to update to Win 8.1 (from 8) this morning, so I’m still working on reinstalling the drivers. One is demanding a reboot just now.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!