Storing a 1x500-double that's imbedded in a loop
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Kevin Krone
le 10 Déc 2020
Commenté : Steven Lord
le 10 Déc 2020
Hello all,
My question lies in how to output or store each value of "v" that is inside my for loop.
I know I can leave it unsupressed and it will pop out 10 different 1x500 doubles in the command window, but what I really want is for the loop to output "v" everytime it iterates, essentially giving me something like v1, v2, v3... v10 so I can look at each 1x500 double individually.
If anyone can offer any help, guidance, or advice I would truly appreciate it. This doesn't seem like something too hard to do but I am quite the noob when it comes to using MATLAB, so I apologize in advance if this is something blatanly obvious that I just don't know how to do.
clc
clear all
t = linspace(0,30,500);
g = 9.81;
m = [0.0008877 0.0017754 0.0026631 0.0035508 0.0044385 0.0053262...
0.0062139 0.0071016 0.0079893 0.008877];
rho = 1.225;
A = 0.19113;
Cd = 0.819346574;
k = (1/2).*Cd.*rho.*A;
v = zeros(1,10);
% Vt = zeros();
% Y = zeros();
% x = zeros();
for i=1:10
Vt = sqrt((m(1,i).*g)./k);
Y = (g.*t)./Vt;
v = Vt.*tanh(Y.*(pi/180));
plot(t,v)
hold on
end
0 commentaires
Réponse acceptée
Walter Roberson
le 10 Déc 2020
v(i,:) = Vt.*tanh(Y.*(pi/180));
plot(t, v(i,:));
2 commentaires
Steven Lord
le 10 Déc 2020
Think about trying to fit half a dozen eggs into a single cup of an egg carton. You can't do it unless the cup is MUCH larger than the eggs (quail eggs inside an egg carton designed for ostrich eggs) or you scramble the eggs (and even then you'd likely have a volume issue.) That's the equivalent of A(1) = 1:6;
If you have an egg carton with two rows and six cups in each row, you can easily fit the six eggs into one row of the carton. That's the equivalent of A(1, :) = 1:6; assuming A is something like zeros(2, 6).
A = zeros(2, 6);
A(1, :) = 1:6 % works
A(1) = 7:12 % errors
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!