-
November 22nd, 2012, 10:24 AM
#1
How to write multiple files in Matlab
Hello everyone! I'm fairly new to Matlab, and I'm facing a task that is very difficult.
I have a program, used to analyze some data collected, and I need an outcome with a series of matrices. I'm stuck in how to write those matrices, with a for cycle. I've come up with this
Code:
for i=20:40
filenamewrite = (['ev_media' num2str(i) '.dat'],'i');
filewrite = [pathwrite filenamewrite];
end
but it comes up with a warning saying that: "Expression or statement is incorrect--possibly unbalanced (, {, or [.
And this is what the program will have to do (the first for is what I added, all the other operations are from the previous program, that I have to repeat for a certain number of times)
Code:
for k=21:40
for i = 1:II %this recombines the matrices studied, to be plotted on a different software
for j = 1:JJ
III(i,j) = i;
JJJ(i,j) = JJ+j-1;
end
end
IIrs = reshape(III,II*JJ*K,1);
JJrs = reshape(JJJ,II*JJ*K,1);
Uboxrs = reshape(Ubox,II*JJ*K,1);
Vboxrs = reshape(Vbox,II*JJ*K,1);
MatrOutput = [IIrs JJrs Uboxrs Vboxrs]; %I need this for all the output matrices.
%MatrOutput = [IIrs JJrs Xboxrs Yboxrs Uboxrs Vboxrs];
dlmwrite(filewrite,['Variables="x","y","Ubox","Vbox"'],'')
dlmwrite(filewrite,['Zone T="Snapshot=1"'],'-append','delimiter','')
dlmwrite(filewrite,['I=21,J=26,K=1'],'-append','delimiter','')
dlmwrite(filewrite,MatrOutput,'-append','delimiter','\t','precision','%15.10f')
end
Can any of you, please, give me some help on this?
Last edited by GremlinSA; November 23rd, 2012 at 07:09 AM.
Reason: applied code tags
-
November 23rd, 2012, 12:12 AM
#2
Re: How to write multiple files in Matlab
-
November 23rd, 2012, 04:28 AM
#3
Re: How to write multiple files in Matlab
I don't need to know how to read it, because I've already done that. I just need to know if my code is correct, or if there is an easier way to make MatLab write multiple files.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|