Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私はファイルdata.txtを持っています
1 22 34 -2 3 34 -3 2 3 43 -3 2 3
そして、このファイルを別の行列として Octave にロードしたい
matrix1 = [1; 22; 34 ;-2] matrix2 = [3; 34 -3] . . .
どうすればいいですか?fopen と fgetl を試してみましたが、マトリックス内で各文字に独自の場所が割り当てられているようです。文字ではなく値を区切りたいです(スペースで区切られています)。
迅速かつ汚い:
A = dlmread("file"); matrix = 1; # just for nice varname generation for i = 1:size(A,1) name = genvarname("matrix",who()); eval([name " = A(i,:);"]); eval(["[_,__," name "] = find(" name ");"]); end clear _ __ A matrix i
フォーマットは指定したとおりである必要があります。