How can I use a symbolic variable in a for-loop?
Afficher commentaires plus anciens
Hello, I try to simulate the wave acceleration of irregular waves, which is defined as: a = ut/dt So I created a symbolic variable for the derivation (diff), my problem is to involve the symbolic variable in the for loop. I get the following error:
Error using mupadmex
Error in MuPAD command: Dimensions do not match. [(Dom::Matrix(Dom::ExpressionField()))::_mult2]
Error in sym/privBinaryOp (line 1694)
Csym = mupadmex(op,args{1}.s, args{2}.s, varargin{:});
Error in sym/mtimes (line 184)
X = privBinaryOp(A, B, 'symobj::mtimes');
%% calculate irregular waves
syms time;
t = 0:dt:180; %modeling with dt = .1 s
u3 = zeros(50,length(t));
phase = 2*pi*rand(50);
for j = 1:50
u3(j,:) = u2(j)*sin(omega(j).*time + phase(j));
end
u4=sum(u3);
a4 = diff(u4,time);
-----------------------------------
u2 and omega are 1x50 matrices
---------------------------------------
Thanks in advance!
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Common Operations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!