Enter multiple values for a single variable
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Shane
am 28 Mär. 2025
Kommentiert: Mathieu NOE
am 28 Mär. 2025
Hello, I'm trying to figure out a problem as I am trying to return to MatLab after being away from it for almost 30 years. This program has come a long way for sure. Here we go:
I have multiple constants:
Pa=101.3
B=0.0065
Ta=288.1500
g=9.81
R=286.9
I used linspace to create the 15-item vector (evenly spaced) that I wanted the equation to cycle through
z = linspace(0,11000,15)
I tried a for loop to run the equation over the amount of numbers in z
for idx = 1:length(z)
eqn = Pa(1-(z.*B/Ta))^(g/(BR));
p=solve(eqn,z);
end
You can see my error and I don't know how to fix it. Thanks.
0 Kommentare
Akzeptierte Antwort
Mathieu NOE
am 28 Mär. 2025
hello and welcome back after all this time
In my eyes you are not solving an equation you just computing the numerical output from the given equation and parameters (all defined)
just remember to use the dot operator when you are delaing with arrays / vectors
so I believe the goal is to plot the out(put) vs z ?
Pa=101.3;
B=0.0065;
Ta=288.1500;
g=9.81;
R=286.9;
z = linspace(0,11000,15);
out = Pa*(1-(z.*B/Ta)).^(g/(B*R));
plot(z,out);
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical 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!