Missing something obvious? (fscanf)
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Trying to use fscanf to read data from a file that is 24 rows by 5 columns. I've set up this:
[fileId,errorMsg] = fopen('Data.txt', 'r');
if fileId < 0
disp(errorMsg);
else
NUMROWS = 24;
for row = 1:NUMROWS
for col = 1:5
data(row,col) = fscanf(fileId, '%d', inf);
end
end
end
but I keep getting a "Subscripted assignment dimension mismatch." error when I run it. Not sure if I'm missing some obvious error or if I'm just doing this wrong to begin with.
Thanks very much for your help in advance.
4 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
Image Analyst
am 21 Mär. 2013
You can only assign one value to data(row,col) so why do you have inf instead of 1? Anyway, why don't you just use fread() to read the whole stream of data into a 2D array directly? Why use fscanf()?
Siehe auch
Kategorien
Mehr zu Matrix Indexing 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!