Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

How do you plot with a double for loop? I want to plot the last value of U with respect to c_2 continuously, having a nice curve.

1 Ansicht (letzte 30 Tage)
%%Parameters
format short
% Constants
rho=1.225;
U=170;
s=1;
c=0.5;
c_2=1;
b=0.5*c;
m=5;
I_CG=0.05;
k1=10000;
k2=10000;
k3=10000;
m_p=0.5;
% x_p=(0:0.01:c);
zero=[0 0; 0 0];
% Variables
x_g=0.5*c;
x_1=0.1*c;
x_ac=0.25*c;
x_3=0.7*c;
q=0.5*rho*u^2;
u_final = zeros(1, numel(0:0.1:20));
counter = 1;
for c_2=[0:0.1:20]
for u = [0:1:75]
M=[ m -m*(x_ac - x_g); -m*(x_ac - x_g) I_CG + m*(x_ac - x_g)^2 ];
E=[k1 + k2 + k3 k1*(x_1 - x_ac) + k3*(x_3 - x_ac); k1*(x_1 - x_ac) + k3*(x_3 - x_ac) k1*(x_1 - x_ac)^2 + k3*(x_3 - x_ac)^2];
B=[1+c_2/(pi*s*c*rho) c/2; 0 c^2/16];
Bbar=pi*s*c*rho*[B];
K=[0 1; 0 0];
Kbar=pi*s*c*rho*[K];
A=[[M] u*[Bbar];[zero] [M]];
C=[[zero] [E]+u^2*[Kbar] ; -[M] [zero] ];
c_2;
u;
lambda=eig(C,-A);
if any(lambda>0)
u_final(1, counter) = u;
counter = counter + 1;
break
end
end
end
figure(4)
set(gcf,'color','w');
plot (0:0.1:20,u_final,'r')
xlabel ('Dampening Magnitude c_2');
ylabel ('Speed Limit [m/s]');
axis([0 20 0 80 ])
grid on

Antworten (1)

KSSV
KSSV am 21 Nov. 2017
%%Parameters
format short
% Constants
rho=1.225;
U=170;
s=1;
c=0.5;
c_2=1;
b=0.5*c;
m=5;
I_CG=0.05;
k1=10000;
k2=10000;
k3=10000;
m_p=0.5;
% x_p=(0:0.01:c);
zero=[0 0; 0 0];
% Variables
x_g=0.5*c;
x_1=0.1*c;
x_ac=0.25*c;
x_3=0.7*c;
% q=0.5*rho*u^2;
u_final = zeros(1, numel(0:0.1:20));
counter = 1;
figure(4)
hold on
set(gcf,'color','w');
xlabel ('Dampening Magnitude c_2');
ylabel ('Speed Limit [m/s]');
axis([0 20 0 80 ])
grid on
for c_2=[0:0.1:20]
for u = [0:1:75]
M=[ m -m*(x_ac - x_g); -m*(x_ac - x_g) I_CG + m*(x_ac - x_g)^2 ];
E=[k1 + k2 + k3 k1*(x_1 - x_ac) + k3*(x_3 - x_ac); k1*(x_1 - x_ac) + k3*(x_3 - x_ac) k1*(x_1 - x_ac)^2 + k3*(x_3 - x_ac)^2];
B=[1+c_2/(pi*s*c*rho) c/2; 0 c^2/16];
Bbar=pi*s*c*rho*[B];
K=[0 1; 0 0];
Kbar=pi*s*c*rho*[K];
A=[[M] u*[Bbar];[zero] [M]];
C=[[zero] [E]+u^2*[Kbar] ; -[M] [zero] ];
c_2;
u;
lambda=eig(C,-A);
if any(lambda>0)
u_final(1, counter) = u;
counter = counter + 1;
break
end
end
plot (0:0.1:20,u_final,'r')
end

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by