how to calculate the derivative of a matrix

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
Rik am 9 Dez. 2022
Can you post example data and show the code you tried?
soheil zare
soheil zare am 9 Dez. 2022
plot(depth01 , load01 , "g")
I actually want to draw the tangent to the graph at the maximum load.
Rik
Rik am 9 Dez. 2022
And what code did you try to determine the derivative?
Jan
Jan am 9 Dez. 2022
The tangent at the maximum is horizontal. So you do not need the derivative.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Rik
Rik am 9 Dez. 2022
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
soheil zare am 9 Dez. 2022
I actually need the red line which shows the limit of the derivative of the load wrt the depth when load is going to maximum.
Rik
Rik am 9 Dez. 2022
How would you attempt to do that? Surely you must have some idea.
soheil zare
soheil zare am 9 Dez. 2022
Actually it should work as findind thr slope of the tangent of the max load point which I have no Idea how to find it.
Rik
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
soheil zare am 9 Dez. 2022
lets say the line tangent to the loads in positions (114000 to 120000)
Rik
Rik am 10 Dez. 2022
If you needed to calculate the slope of those positions by hand, how would you do that?
soheil zare
soheil zare am 10 Dez. 2022
by hand it woud not be accurate but by fomula it is ( lim dLoad/dDepth when Load goes to Load max ).
anyway by ahand it would be like the red line tangent to the selected part of thr graph which is uploaded .

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Just for fun finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2022b

Gefragt:

am 8 Dez. 2022

Kommentiert:

am 10 Dez. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by