Retaining values for a Matrix!
古いコメントを表示
I have a matrix A. A has dimensions (10,100). I also have 10 different text files.Each text file loads 100 binary values.I have written a script which loads a text file,copies all the 100 binary values in A and displays A.I want A to retain all the rows for 10 text file loads serially.I am loading the text files serially i.e I take one text file, load it, copy its data into A,then again replace the previous text file with the new one, run the script again , load new values in A...till all the text files are loaded. How can I achieve this? To save all the previous data in a matrix even after running the same script with new inputs multiple times Help appreciated! Waiting..
2 件のコメント
Kaushik Lakshminarasimhan
2017 年 11 月 24 日
It'll be a lot easier to help if you share your script.
Hrishikesh lele
2017 年 11 月 25 日
回答 (1 件)
Rik
2017 年 11 月 25 日
The answer is not overwriting the result, but using a cell, or assigning the result of your function to only part of your matrix.
%option1
A=cell(10,1);
for n=1:10
A{n}=logical(rand(1,100));
disp(A{n})
end
%option2
A=false(10,100);
for n=1:10
A(n,:)=logical(rand(1,100));
disp(A(n,:))
end
2 件のコメント
Hrishikesh lele
2017 年 11 月 25 日
Rik
2017 年 11 月 25 日
Which is why you need to add a loop. Just save the filenames in an array as well. You want to repeat a script. Matlab has two tools for that: for-loops and while-loops. I guess you could also trick a recursive function to do it, but that is over-complicating it.
カテゴリ
ヘルプ センター および File Exchange で Numeric Types についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!