0

i am trying to read and store 10 data file using a For loop in octave. 10 text file which are point1 , point2, ..., point10. The code sopposed to to read them and store them as vertex1, vertex2, ..., vertex10 then more calculation on them. but the line ' vertex([num2str(k)])=pit;' does not work.

the written code is:

for k = 1 : 10
pointID = num2str(k);
fid=fopen(['point' pointID '.txt']);
pit=fscanf(fid,'%f %f %f %f %f',[5 Inf] );
fclose(fid);
pit=pit';
vertex([num2str(k)])=pit;
end;

the error:

error: dataEvluationVahidScript: =: nonconformant arguments (op1 is 1x1, op2 is 100x5)

*100x5 is input matrix size.

Any help would be appreciated. Greetigs

  • What you're trying to do is called Dynamic Variable Naming. [This is bad, very bad](https://stackoverflow.com/a/32467170/5211833) for a plethora of reasons (execution speed and code obfuscation amongst those). Instead, store them in a proper way: if all your `pit` variables have equal size, store them in a matrix. If they don't, store them in a cell or structure, whichever is more appropriate for your case. – Adriaan Feb 17 '22 at 09:50

0 Answers0