Calling matrices from workspace to For loop in MATLAB

  • MATLAB
  • Thread starter omri3012
  • Start date
  • #1
62
0

Main Question or Discussion Point

Hallo,

I have matrices on my workpace and i need to take the first element from each one
and produce new vector. In other words, i have the matrices D1,D2,D3....D36 on my workspace and by using a For loop i want to generate a new vector:
d=[D1(1,1) D2(1,1)...D3(1,1)].
does anyone know how to that in For loop?

Thanks,
Omri
 

Answers and Replies

  • #2
166
0
How about this:
Code:
for i = 1:36
    s = sprintf('d(i) = D%g(1,1);',i);
    eval(s);
end
 
  • #3
62
0
Thanks,
It's working now, i really appreciate it!

Omri
 
Last edited:

Related Threads on Calling matrices from workspace to For loop in MATLAB

Replies
1
Views
710
  • Last Post
Replies
3
Views
3K
  • Last Post
Replies
2
Views
3K
Replies
2
Views
985
  • Last Post
Replies
5
Views
4K
Replies
1
Views
2K
Replies
1
Views
2K
Replies
1
Views
4K
Replies
4
Views
6K
Top