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: sprintf to read inside a matrix
Replies: 1   Last Post: Dec 2, 2013 2:02 PM

Advanced Search

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

Posts: 25
Registered: 11/26/12
sprintf to read inside a matrix
Posted: Dec 2, 2013 11:37 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Dear all,

I am trying to use a loop to read into different matrices which are: results_USA, results_UK, results_JAP and results_UK. I am trying to do it with a loop using sprintf

%% here is my code

c={'USA','EUR','JAP','UK'};

for j=1:length(c)

for i=0:10

AA=sprintf('results_%s',c{j})

[zMin,idx]=min(AA(:,i+1:i+5),[],2);
end

end

%% my problem is that matlab tells me that there is a dimension mismatch because it does not recognize the size of AA even though I set AA equal to "results_USA", "results_UK", "results_JAP" or "results_EUR".

I would like to use the output of sprintf('results_%s',c{j}) without having to rename the matrix "results_USA" (i.e. i would like Matlab to recognize the name of the matrix it reads)

Thank you very much for your help

S



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

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.