Retaining values for a Matrix!
Mostra commenti meno recenti
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 Commenti
Kaushik Lakshminarasimhan
il 24 Nov 2017
It'll be a lot easier to help if you share your script.
Hrishikesh lele
il 25 Nov 2017
Risposte (1)
Rik
il 25 Nov 2017
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 Commenti
Hrishikesh lele
il 25 Nov 2017
Rik
il 25 Nov 2017
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.
Categorie
Scopri di più su Numeric Types in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!