how to calculate the derivative of a matrix
Ältere Kommentare anzeigen
I have 2 huge data as 2 separate matrixes which gives me a graph.I want to calculate the derivative of the graph at the maxmum and draw the tangent line .
4 Kommentare
Rik
am 9 Dez. 2022
Can you post example data and show the code you tried?
soheil zare
am 9 Dez. 2022
Rik
am 9 Dez. 2022
And what code did you try to determine the derivative?
Jan
am 9 Dez. 2022
The tangent at the maximum is horizontal. So you do not need the derivative.
Antworten (1)
Jan has all but given you the function you should be using: the max function.
S=load(websave('data.mat','https://www.mathworks.com/matlabcentral/answers/uploaded_files/1225492/load%20depth.mat'));
depth01=S.depth01;
load01=S.load01;
plot(depth01 , load01 , "g")
[max_load,max_ind]=max(load01);
max_depth=depth01(max_ind);
hold on,plot(max_depth,max_load,'r*'),yline(max_load,'r'),hold off
7 Kommentare
soheil zare
am 9 Dez. 2022
Rik
am 9 Dez. 2022
How would you attempt to do that? Surely you must have some idea.
soheil zare
am 9 Dez. 2022
Rik
am 9 Dez. 2022
I already showed you how you can find the maximum value in an array and how to find the corresponding position. How do you think you could use that to find the points on that part of the curve?
You essentially want to fit a line through a group of points. How do you think you can find those points? My code is almost enough. Just the final step is missing. Think about what steps you need to take if you wanted to do this by hand.
soheil zare
am 9 Dez. 2022
Rik
am 10 Dez. 2022
If you needed to calculate the slope of those positions by hand, how would you do that?
soheil zare
am 10 Dez. 2022
Kategorien
Mehr zu Just for fun finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

