How do i save values in a loop to vectors?
3 次查看(过去 30 天)
显示 更早的评论
How do i save values in a loop to vectors? for my example i want z1 and z2 to becomes vectors of each responding values of Z. Here is my try on writting the code.
-(for n=1:length (Vv)
f=(Vv(n))
A = [Kq+i*(2*pi*f)*Cq-((2*pi*f)^2)*Mq]
G =[0;((kt+i*(2*pi*f)*ct)*Stak)]
Z=A\G;
z1 = Z (1)
z2 = Z (2)
end)
0 个评论
采纳的回答
madhan ravi
2020-12-7
V = cell(2, 1); % an example on how to store
for l = 1 : 2
V{l} = rand(2, 1);
end
celldisp(V)
3 个评论
madhan ravi
2020-12-7
[z1, z2] = deal( zeros(numel(Vv), 1) );
for n = 1 : numel(Vv)
f = Vv(n);
A = Kq + i * ( 2 * pi * f ) * Cq - ( ( 2 * pi * f ) ^ 2 ) * Mq
G = [0; ( ( kt + i * ( 2 * pi * f ) * ct ) * Stak ) ]
Z = A \ G;
z1(n) = Z(1);
z2(n) = Z(2);
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!