MATLAB: In an assignment A(I) = B, the number of elements in B and I must be the same.

assignment a(i) = bMATLABthe number of elements in b and i must be the same.

Hello, I'm getting the following error:
  • * ***COMMAND WINDOW***** * *In an assignment A(I) = B, the number of elements in B and I must be the same.
Error in C_B_HW_9 (line 22) Comfort(count)=('cold');
  • * *This is the script <file:*> * *
for count=1:1:20
C(count) = -50+200*rand(1);
K(count) = C(count)+273.15;
F(count) = C(count)*9/5+32; %converting celsius to fahrenheit
R(count) = C(count)*1.8+491.67;
if F(count)>32
if F(count)>55
if F(count)>70
if F(count)>90
if F(count)>105
Comfort(count)=('!!!');
else
Comfort(count)=('hot');
end
else
Comfort(count)=('warm');
end
else
Comfort(count)=('mild');
end
else
Comfort(count)=('cold');
end
else
Comfort(count)=('freeze');
end
end
for count=1:20
fprintf('\n %.0f %.0f %.1f %.2f %.1f %s\n', count,C(count), K(count), F(count), R(count), Comfort(count));
end

Best Answer

strings are vectors of characters, not indivisible units. If your string is 4 characters long then you need to store it into 4 locations.
You may wish to consider using cell arrays.
Comfort{count} = 'mild';
notice the {} instead of (). Same goes when you want to retrieve, Comfort{count}