Graphical construction (max, min, tangent line in a point) from simulink scope / multiplot graph

조회 수: 15 (최근 30일)
Hi all, i've the graph from a simulink simulation in a multiplot graph;
then i need to find the point of maximum slope of that graph (along with its x, y coordinates), in that point i need to plot the tangent line to the graph, and then plot the intersections with x axis and the extrapolation from max value of graph of this tangent line. To make simpler to explain i've an image of what i would to obtain:
I've already tried to send graph data to workspace, but then plotting it i lose the time x axis...
Any help would be very appreciated.

채택된 답변

Paulo Silva
Paulo Silva 2011년 7월 28일
Using the To Workspace block
  1. Insert the block in your simulation and connect it to the desired output
  2. Open the To Workspace parameters and change the save format to Structure with time
Do the simulation and the data appears on the workspace, you can use it and plot it like this
plot(simout.time,simout.signals.values)
  댓글 수: 2
Michele
Michele 2011년 7월 28일
Thanks Paulo Silva, your reply has helped me to plot with right x-axis; now can you be so kindly to show me how to obtain the maximum slope point of the curve and then drawing the tangent curve at the plot in that point?
Paulo Silva
Paulo Silva 2011년 7월 28일
Michele we expect you and everyone else to show some effort at solving the problems, we are here to help at specific questions, not to do all your work.
Here's more code but please try to understand it to finish what you want, the only thing that's missing is the line, the code gives you the slope and you can easily find the maximum slope.
si=simout.signals.values;
st=simout.time;
cla;hold on
plot(st,si)
d=diff(si)./diff(st); %d is the slope of the signal
[C,I]=max(d); %find maximum of the slope C and the index I where the slope is
plot(st(1:end-1),d,'r')
legend('signal','slope')

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Michele
Michele 2011년 7월 29일
Thank you vary much, Paulo, with our right and precious directions i'm almost done:
now my last problem is to find point of curve such as
max = max of curve t1 = .268*max t2 = .632*max
i've tryed with find(si == .268*max) but it returns an empty matrix... Thanks again.
  댓글 수: 3
Michele
Michele 2011년 7월 29일
Thanks,
the first answer finds the first element in vector which is >= st1; and it works.
Just for curiosity, i've tried with interp1, but it "interpolates to find yi, the values of the underlying function Y at the points in the vector or array xi. "
infact by doing
yi = interp1(st,si,50,'spline')
it finds the correct value of function at x=50;
but i need the inverse compute: given yi, i would to find the xi, in this case can i also use interp1?

댓글을 달려면 로그인하십시오.


Nelis Vandermeiren
Nelis Vandermeiren 2011년 12월 30일
Hello
I need to do the same thing, but here is my question: How can you plot the tangent line on the (step-response) graphic where the slope is max? and how to add those intersection points?

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by