all loop values in one vector

1 次查看(过去 30 天)
amr atyia
amr atyia 2016-4-17
what is the problem please ?
z=[];
for n=2:length(acc_norm)-1;
if abs(acc_norm(n,:))>max(abs(acc_norm(n-1,:)),abs(acc_norm(n+1,:)))
Sc='Speak';
elseif abs(acc_norm(n,:))<min(abs(acc_norm(n-1,:)),abs(acc_norm(n+1,:)))
Sc='Svalley';
else Sc='Sintmd';
end
z=[z;Sc];
end

回答(1 个)

Walter Roberson
Walter Roberson 2016-4-18
Remember that strings are not entities in themselves: strings are row vectors of characters. So Sc='Speak'; is setting Sc to a row vector of length 5, and Sc='Svalley' is a row vector of length 7. Your z=[z;Sc] is then attempting to put together row vectors of different lengths.
I suggest you use
z{end+1} = Sc;

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by