Info

This question is closed. Reopen it to edit or answer.

Hello my dear,How can I write this error? Thank all.

3 views (last 30 days)
Zin Ko Khaing
Zin Ko Khaing on 25 Apr 2019
Closed: MATLAB Answer Bot on 20 Aug 2021
Hello all,
How can I write this error? I have some error this program. Please help me. Thank all. Program is below. If you can, please write to this.
for t=1:N
if(t<y)
vm=vm2(t);
else
vm=440*sqrt(2)/sqrt(3);
end
va(t)=vm*sin(2*pi*60*t*dt);
vb(t)=vm*sin(2*pi*60*t*dt-(2*pi)/3);
vc(t)=vm*sin(2*pi*60*t*dt+(2*pi)/3);
end
Error is-

Answers (1)

Adam Danz
Adam Danz on 25 Apr 2019
Edited: Adam Danz on 15 May 2019
These aren't errors. They are warnings. Your variables isq, isd, frq, frd and wr are created within a loop and on each iteration of the loop, their size changes. Instead, you want to allocate the variables before the loop. Here's an example:
I don't know if these variables are vectors, matrices, numeric, cell arrays, etc.
n=12;
isq = zeros(1,n); % <- allocate a numeric vector
for i = 1:n
isq(i) = rand(1);
end
Here are more allocation examples.
isq = cell(1,n); % <- cell array, empties
isq = nan(n,3); % <- n x 3 matrix, NaNs

This question is closed.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!