Drexel dragonThe Math ForumDonate to the Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Using for loop for different matrices
Replies: 1   Last Post: Dec 7, 2012 7:58 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 69
Registered: 2/22/12
Re: Using for loop for different matrices
Posted: Dec 7, 2012 7:58 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Bas v S" <b.vanschravendijk@student.tudelft.nl> wrote in message <k9sisc$ail$1@newscl01ah.mathworks.com>...
> Dear all, I have a problem with using a for loop for different matrices
> I have a couple of matrices:
> Run1=<3600x6 double>
> Run2=<3600x6 double>
> Run3=<3600x6 double>
> Run4=<3600x6 double>
> etc...
> For each Run#, I want to:
> F1=mean(Run1(:,1));
> F2=mean(Run1(:,2));
> F3=mean(Run1(:,3));
> etc...
> I've tried the following:
> Runtot={Run1, Run2, Run3, ...}
> for i=1:1:length(Runtot)
> F1(i)=mean(Runtot(1,1,:))
> F2(i)=mean(Runtot(1,2,:))
> etc..
> end
> But i cannot acces Runtot(1,1,1). When I ask for it, Matlab only shows the dimensions of the matrix.
> Hope anybody can help me out!
> Thnx!

Because of the curly brackets "{" that you've used to define Runtot, you have made a cell array. Access it elements with curly brackets, e.g.
F1(i) = mean(Runtot{1,1,:});

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum 1994-2015. All Rights Reserved.