Generating a plot using shm function

2 views (last 30 days)
Hi, I am trying to plot the SHM function online. I kind of plotted the first part of the curve but need further help with it.
x=0:0.1:10;
x1=10:0.1:0;
y=smf(x,[0,9]);
plot(x,y);
ylim([0 1.05]);
I want a curve which starts from (10, 1) and drops to (0,0.6) in the figure that I have attached. Can anyone help me with how to draw that curve? Thanks :)

Accepted Answer

Image Analyst
Image Analyst on 3 Apr 2015
Call "hold on" and then get a new y with different parameters. Then call plot() again with the new y.
  1 Comment
Image Analyst
Image Analyst on 4 Apr 2015
How about:
x=0:0.1:10;
y=smf(x,[0,9]);
plot(x,y); % Forward direction.
ylim([0 1.05]);
hold on;
x1=10:0.1:0;
y=smf(x1,[0,9]);
plot(x1,y); % Reverse direction.

Sign in to comment.

More Answers (0)

Categories

Find more on Physics 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!