MATLAB Answers

# How to plot multiple graphs using the 3 variable array values

51 views (last 30 days)
muhammad choudhry on 19 Oct 2020
Commented: Steve Eddins on 19 Oct 2020
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 CommentsShowHide 1 older comment
muhammad choudhry on 19 Oct 2020
many graph in the same image! please!

Sign in to comment.

### Accepted Answer

Steve Eddins on 19 Oct 2020
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 CommentsShowHide 1 older comment
Steve Eddins on 19 Oct 2020
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).

Sign in to comment.

### Community Treasure Hunt

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

Start Hunting!

Translated by