load some file from matfile used iteration??

4 Ansichten (letzte 30 Tage)
naimah lubis
naimah lubis am 29 Okt. 2011
hello all :), i've got small problem to load some file from matfile used iteration. the condition is explained below:
load imagelatih1;
w1=vector;
load imagelatih2;
w2=vector;
load imagelatih3;
w3=vector;
load imagelatih4;
w4=vector;
load imagelatih5;
w5=vector;
...
...
load imagelatihn;
wn=vector;
w=[w1; w2; w3; w4; w5......wn]
i can't used the code above cause its from 1...n.
the code with iteration:
for k=1:n
myfilename = sprintf('imagelatih%d', k);
data=load (myfilename, 'vector');
end
i can't access 'vector' in each imagelatih.mat to make w=[w1; w2; w3; w4; w5......wn].
how can i do that???
any help?
  1 Kommentar
Amith Kamath
Amith Kamath am 30 Okt. 2011
could you elaborate on what you mean by can't access 'vector'? What is the error message that you get? I suppose the code snippet you wrote is good, but unless the error is known, I'm not sure how anyone could answer this question.. does it say warning: vector not found?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Fangjun Jiang
Fangjun Jiang am 30 Okt. 2011
Either use just load(myfilename,'vector') without the return argument 'data'. The variable 'vector' will be in the workspace.
Or, the variable is loaded into a strcture. Check the value of data.vector
In your case, you don't even need to name them. Just set w=[] at the beginning and then run w=[w;vector] or w=[w;data.vector] inside the loop.
  1 Kommentar
naimah lubis
naimah lubis am 30 Okt. 2011
thanks for the answer..
u are right, i can do that. Just use load(myfilename,'vector') and set w=[w;vector]..
thanks a lot..:)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Deep Learning Toolbox 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!

Translated by