Hello I am new to matlab and would like your help. I have a program that reads the file. Mat. When I read that file to transform vector data matrix and so I need to save it in excel. But I have 50 files. Mat and need to save all vectors one after another in excel so they become a single vector in excel. I greatly appreciate any help.

8 Commenti

Image Analyst
Image Analyst il 15 Dic 2013
I don't understand what the sentence "Mat." means, nor do I understand what the sentence that starts out "Mat and need to save...." means. Please clarify.
If you need to deal with 50 Excel workbooks you will need to use ActiveX unless you are okay with waiting a very very long time for it to finish. Let me know and I can give you an ActiveX demo.
Jadiel Silva
Jadiel Silva il 15 Dic 2013
Hi, Thanks for trying to help me. I'll try to explain in more detail and we'll talk. .mat is a kind of extension, like .m, .doc. So I have a array saved within that file .mat. Through a program I read this file .mat later I transformos a matrix into a vector. So I believe the first step is to save this vector in excel. Later I have another 50 vectors and want to save them all in excel one after the other, so that the excel stay with a single vector. These 50 vectors become just one vector within excel. I have helped Thank you very much
Azzi Abdelmalek
Azzi Abdelmalek il 15 Dic 2013
Modificato: Azzi Abdelmalek il 15 Dic 2013
What are the sizes of your vectors? Maybe you can concatenate them, then save your data once
Jadiel Silva
Jadiel Silva il 15 Dic 2013
The array is 500 x 500, then each vector are 250000.
Azzi Abdelmalek
Azzi Abdelmalek il 15 Dic 2013
Why do you want to save a 500x500 array as a 250000 vectors, and if you have 50 files, does that mean you want to save a 5*250000 vector?
Jadiel Silva
Jadiel Silva il 15 Dic 2013
No. Within each file .mat there is a matrix 500x500 transforming for vector, gives a vector of 250000. Now I have 50 files .mat, ie I have 50 matrix 500x500 or I have 50 vetors 250000 I want to save them one after the other in a single vector in excel.
Image Analyst
Image Analyst il 16 Dic 2013
Can Excel handle 12.5 million rows? If it can, I agree with Azzi, just concatenate them all in MATLAB, then call xlswrite() just once with the 12.5 million element vector.
Azzi Abdelmalek
Azzi Abdelmalek il 16 Dic 2013
Modificato: Azzi Abdelmalek il 16 Dic 2013
I don't think Excell can handle 12.5 millions rows.It's better to save each matrix in different sheet

Accedi per commentare.

 Risposta accettata

Azzi Abdelmalek
Azzi Abdelmalek il 15 Dic 2013
Modificato: Azzi Abdelmalek il 16 Dic 2013
I don't know, why you want to save them all as one vector instead a matrix 2500x500. But if you want to save your data as a vector, load your data in your files, concatenate them in one vector v then write
xlswrite('file.xlsx',v)
To load your files, put all your 50 files in one folder, for example D:\yourfolder. If your array is named M in your files:
folder='D:\yourfolder'
d=dir('*.mat')
for k=1:numel(d)
data=lod(d(k).name);
M=data.M;
v=[v;M(:)];
end
xlswrite('file.xlsx',v)

5 Commenti

Jadiel Silva
Jadiel Silva il 16 Dic 2013
Thanks Azzi, I think that was exactly what I needed. thank you very much
Jadiel Silva
Jadiel Silva il 16 Dic 2013
Azzi, excuse my ignorance with programming in matlab, but I have one more question. If I make this your routine: folder='D:\yourfolder'
d=dir('*.mat')
for k=1:numel(d)
data=lod(d(k).name);
M=data.M; v=[v;M(:)];
end
xlswrite('file.xlsx',v)
I'll be saving only the vector "v" in excel, right? I performed this routine and it happened, saved my vector "v" to 25000 in the excel spreadsheet. So I save all my 50 vectors I need to do it one by one or is there another way I can do in matlab?
For example:
I first squeegee the program that reads all my files mat.. After in screen matlab I type, for example:
X = Person(1).Angry.Frame(1).APDI;
and it shows me my matrix 500x500.
After I make X = X (:) that vectorizes this matrix 500x500, returning me an array of 250000. Then I do the routine that you gave me and saves only the X, which is only for the first frame, but as I have 50 frames I need to get going one by one and go on saving excel?
Could for example use:
xlswrite('file.xlsx',X)
after Y=Person(1).Angry.Frame(2).DepthMap; Y=Y(:);
xlswrite('file.xlsx',Y,'A250001:A500001);
and so on until you reach the frame 50, or is there another easier way to do this in matlab?
Sorry to bother you with this, but I'm new to matlab and their help has been very valid.
Thank you very much.
Image Analyst
Image Analyst il 16 Dic 2013
v starts out as just one vector but, as the loop iterates, it keeps adding on 250000 elements to v each iteration, until after 50 iterations v will be 12.5 million elements long. Then, after the loop has exited, you call xlswrite() to send v to an Excel workbook disk file.
Hello people. Excuse me, but I need your help again. I'm so ashamed of my ignorance in matlab. I ran the code:
folder='D:\vetor'
d=dir('*.mat')
for k=1:numel(d)
data=lod(d(k).name);
APDI=data.APDI;
v=[v;APDI(:)];
end
but every time I call the function:
xlswrite('file.xlsx',v)
show the message: ??? Undefined function or variable 'v'.
Personal excuse me for being even bothering both you guys with my ignorance in matlab, but the help of you have been very valid and I thank you immensely.
Please can you help me?
v should be initialized
folder='D:\vetor'
d=dir('*.mat')
v=[];
for k=1:numel(d)
data=lod(d(k).name);
APDI=data.APDI;
v=[v;APDI(:)];
end

Accedi per commentare.

Più risposte (0)

Categorie

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by