Graphing a variable function with boundaries problem
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mohsen Nashel
am 24 Sep. 2019
Kommentiert: Mohsen Nashel
am 24 Sep. 2019
i am trying to plot the function that is shown in the picture. Matlab keep giving me the error "Error: File: Q4.m Line: 11 Column: 64
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for
mismatched delimiters."
Refers to P_0_1 in the loop ![Screen Shot 2019-09-24 at 12.52.30 PM.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/239572/Screen%20Shot%202019-09-24%20at%2012.52.30%20PM.png)
![Screen Shot 2019-09-24 at 12.52.30 PM.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/239572/Screen%20Shot%202019-09-24%20at%2012.52.30%20PM.png)
%Part a)
R=287; % Specific gas constant in J/kg.k
M=[2:0.1:6];
gamma=1.4;
P_0_1=101325; % Pressure at sea level in Pa unit
for n=1:length(M);
P_0(n,1)=((1+((gamma-1))/2).*M(n).^2).^(gamma/(gamma-1)).*P_0_1);
end
P_0_ratio=P_0./P_0_1;
figure (1)
plot (M, P_0_ratio)
xlabel('Moch Number')
ylabel('Total stagnation pressure ratio P_0/P_0_1')
title('Total stagnation pressure ratio P_0/P_0_1 vs. Moch Number')
%Part b)
for n=1:length(M);
delta_s_r(n,1)=-log(P_0_ratio(n));
end
figure(2)
plot (M,delta_s_r)
xlabel('Moch Number')
ylabel('Dimensionless entropy change \delta s')
title('Dimensionless entropy change \delta s vs. Moch Number')
0 Kommentare
Akzeptierte Antwort
Ruger28
am 24 Sep. 2019
Bearbeitet: Ruger28
am 24 Sep. 2019
Removing the extra " ) " at the end of that line, yields plots and no errors.
%Part a)
R=287; % Specific gas constant in J/kg.k
M=[2:0.1:6];
gamma=1.4;
P_0_1=101325; % Pressure at sea level in Pa unit
for n=1:length(M);
P_0(n,1)=((1+((gamma-1))/2).*M(n).^2).^(gamma/(gamma-1)).*P_0_1;
end
P_0_ratio=P_0./P_0_1;
figure (1)
plot (M, P_0_ratio)
xlabel('Moch Number')
ylabel('Total stagnation pressure ratio P_0/P_0_1')
title('Total stagnation pressure ratio P_0/P_0_1 vs. Moch Number')
%Part b)
for n=1:length(M);
delta_s_r(n,1)=-log(P_0_ratio(n));
end
figure(2)
plot (M,delta_s_r)
xlabel('Moch Number')
ylabel('Dimensionless entropy change \delta s')
title('Dimensionless entropy change \delta s vs. Moch Number')
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Trajectory and Scenario Generation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!