Why am I getting "Subscripted assignment dimension mismatch."
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Alex
am 29 Nov. 2018
Bearbeitet: Ken Atwell
am 3 Jan. 2019
Hello,
I keep getting this error when I run the code on a certain dataset. but have used this code before without problems. For some reason it does not work past the second iteration.
for k=1:29
h(k,:) =sprintf('aircraft at %3.4f degrees latitude', parnam{1,k}.data(1,1)) ;
end
![Untitled.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/197621/Untitled.png)
0 Kommentare
Akzeptierte Antwort
Ken Atwell
am 30 Nov. 2018
Bearbeitet: Ken Atwell
am 3 Jan. 2019
It looks like you're trying to create a 2D matrix of char(acter)s. For this to work, each char vector needs to be exactly the same length. If you are on a recent-ish version of MATLAB, a vector of string might serve you better:
h = strings(1,29);
for k=1:29
h(k) =sprintf('aircraft at %3.4f degrees latitude', parnam{1,k}.data(1,1)) ;
end
3 Kommentare
Walter Roberson
am 1 Dez. 2018
You do not have "a recent-ish version of MATLAB".
h = cell(1,29);
for k=1:29
h{k} = sprintf('aircraft at %3.4f degrees latitude', parnam{1,k}.data(1,1)) ;
end
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Legend finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!