How to plot multiple graphs using the 3 variable array values

조회 수: 15 (최근 30일)
muhammad choudhry
muhammad choudhry 2020년 10월 19일
댓글: Steve Eddins 2020년 10월 19일
Hi, I am plotting the graph expressing depth over deflection graph: where as the depth increases deflection increases and the code is shown below. I want to add one more variable here length of the tank. lets say in array [0:0.2:3.4] and want to plot the depth over deflection graph when length is 00,0.2,0.4,......3.4.
How would I introduce the 3rd variable into the code below.
Code:
h = [0:0.008:0.600]
rho = 1000
g = 9.81
L = 3.4
F = rho*g*L*(0.5*(h).^2)
F1 = F/1000
E = 2.1E11
I = ((0.008)^4)/12;
Ymax = ((1/48)*((F1*(L^3))/(E*I)))*1000
L1 = [0:0.2:3.4] %3rd variable
plot(Ymax,h)
  댓글 수: 2
Rik
Rik 2020년 10월 19일
Do you want many graphs in the same image, or do you want a 3D point cloud? In the first case I would suggest using a loop, in the second case plot3.
muhammad choudhry
muhammad choudhry 2020년 10월 19일
many graph in the same image! please!

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

채택된 답변

Steve Eddins
Steve Eddins 2020년 10월 19일
Here is one way:
h = 0:0.008:0.600;
rho = 1000;
g = 9.81;
F = rho*g*L*(0.5*(h).^2);
F1 = F/1000;
E = 2.1E11;
I = ((0.008)^4)/12;
L1 = 0:0.2:3.4;
hold on
for L = L1
Ymax = ((1/48)*((F1*(L^3))/(E*I)))*1000;
plot(h,Ymax)
end
hold off
  댓글 수: 2
muhammad choudhry
muhammad choudhry 2020년 10월 19일
Hi,
thanks alot! what is a best way of learning these sort of analysis as I need to generate graph after graph but when it comes to plot multiple data on one graph I am struggling. Would you recommend something which will help me learning it?I only be able to learn how to work with arrays and plotting simple graph but when it is coming to handling 3 variables and alot of data! I am struggling.
Regards,
M Choudhry
Steve Eddins
Steve Eddins 2020년 10월 19일
The "Combine Multiple Plots" documentation page might be helpful to you. It illustrates several techniques, including the one that I used here (with the hold command).

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Directed Graphs에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by