all loop values in one vector

3 visualizzazioni (ultimi 30 giorni)
amr atyia
amr atyia il 17 Apr 2016
Modificato: per isakson il 18 Apr 2016
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

Risposte (1)

Walter Roberson
Walter Roberson il 18 Apr 2016
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;

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by