How to write multiple files in Matlab
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: How to write multiple files in Matlab

Threaded View

  1. #1
    Join Date
    Nov 2012
    Posts
    2

    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 06:09 AM. Reason: applied code tags

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
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center