Azzera filtri
Azzera filtri

How to plot values from a for loop that don't start at x=0?

1 visualizzazione (ultimi 30 giorni)
I am trying to plot values from multiple for loops for different values of x that are greater than 0. I have one for loop from x=100:215 and x=215:230. When I try to plot them in the same plot the two lines are not connected as I would like them to be and they both have a line connecting to the origin. Is there anyway to plot them without the lines connecting to the origin and the two lines connected at x=215
  1 Commento
Jan
Jan il 5 Mar 2016
Without seeing your code, it is hard to guess, why the lines have a connection to the origin.

Accedi per commentare.

Risposte (1)

Jan
Jan il 5 Mar 2016
I do not see the reason for any problem. Perhaps this helps:
x1 = 100:215;
x2 = 215:230;
y1 = rand(size(x1));
y2 = rand(size(x2)) + 2;
plot([x1, x2], [y1, y2]);
  3 Commenti
Jan
Jan il 5 Mar 2016
Please, m13, give us a chance to understand your problem and post the code, which reproduces the effect. We cannot guess what you have written.
Shannon Hemp
Shannon Hemp il 13 Mar 2016
Here is the code that I have. I want to plot time vs thrust.
dt_1=0; dt_2=0;dt_3=0;dt_4=0;
for t=0:100; Pc2_RD_1(t+1) = Pc_RD*(1+(.015*dt_1)^2); Pe_RD_1(t+1) = Pc2_RD_1(t+1)*(1+((gamma_RD-1)/2)*Me_RD^2)^(gamma_RD/(1-gamma_RD)); Isp_RD_1(t+1) = (lamda_RD*c_RD/g0)*(gamma_RD*sqrt((2/(gamma_RD-1))*((2/(gamma_RD+1))^((gamma_RD+1)/(gamma_RD-1)))*(1-((Pe_RD_1(t+1)/Pc2_RD_1(t+1))^((gamma_RD-1)/gamma_RD))))+(e_RD/Pc2_RD_1(t+1))*(Pe_RD_1(t+1)-Pa)); mprop_RD1(t+1) = At_RD*Pc2_RD_1(t+1)/c_RD; thrust_RD1(t+1) = Isp_RD_1(t+1)*g0*mprop_RD1(t+1)/1000; dt_1=dt_1+.2; time(t+1)=t+.2; end
for t2=100:215; Pc2_RD_2(t2) = Pc_RD*(.95+(.008*dt_2)^2); Pe_RD_2(t2) = Pc2_RD_2(t2)*(1+((gamma_RD-1)/2)*Me_RD^2)^(gamma_RD/(1-gamma_RD)); Isp_RD_2(t2) = (lamda_RD*c_RD/g0)*(gamma_RD*sqrt((2/(gamma_RD-1))*((2/(gamma_RD+1))^((gamma_RD+1)/(gamma_RD-1)))*(1-((Pe_RD_2(t2)/Pc2_RD_2(t2))^((gamma_RD-1)/gamma_RD))))+(e_RD/Pc2_RD_2(t2))*(Pe_RD_2(t2)-Pa)); mprop_RD2(t2) = At_RD*Pc2_RD_2(t2)/c_RD; thrust_RD2(t2) = Isp_RD_2(t2)*g0*mprop_RD2(t2)/1000; dt_2=dt_2+.2; time2(t2)=t2+.2; end
for t3=215:230; Pc2_RD_3(t3+1) = Pc_RD*(.98-(.04*dt_3)); Pe_RD_3(t3+1) = Pc2_RD_3(t3+1)*(1+((gamma_RD-1)/2)*Me_RD^2)^(gamma_RD/(1-gamma_RD)); Isp_RD_3(t3+1) = (lamda_RD*c_RD/g0)*(gamma_RD*sqrt((2/(gamma_RD-1))*((2/(gamma_RD+1))^((gamma_RD+1)/(gamma_RD-1)))*(1-((Pe_RD_3(t3+1)/Pc2_RD_3(t3+1))^((gamma_RD-1)/gamma_RD))))+(e_RD/Pc2_RD_3(t3+1))*(Pe_RD_3(t3+1)-Pa)); mprop_RD3(t3+1) = At_RD*Pc2_RD_3(t3+1)/c_RD; thrust_RD3(t3+1) = Isp_RD_3(t3+1)*g0*mprop_RD3(t3+1)/1000; dt_3=dt_3+.2; time3(t3+1)=t3+.2; end
for t4=230:238; Pc2_RD_4(t4+1) = Pc_RD*(.75-(.05*dt_4)); Pe_RD_4(t4+1) = Pc2_RD_4(t4+1)*(1+((gamma_RD-1)/2)*Me_RD^2)^(gamma_RD/(1-gamma_RD)); Isp_RD_4(t4+1) = (lamda_RD*c_RD/g0)*(gamma_RD*sqrt((2/(gamma_RD-1))*((2/(gamma_RD+1))^((gamma_RD+1)/(gamma_RD-1)))*(1-((Pe_RD_4(t4+1)/Pc2_RD_4(t4+1))^((gamma_RD-1)/gamma_RD))))+(e_RD/Pc2_RD_4(t4+1))*(Pe_RD_4(t4+1)-Pa)); mprop_RD4(t4+1) = At_RD*Pc2_RD_4(t4+1)/c_RD; thrust_RD4(t4+1) = Isp_RD_4(t4+1)*g0*mprop_RD4(t4+1)/1000; dt_4=dt_4+.2; time4(t4+1)=t4+.2; end

Accedi per commentare.

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by