MATLAB Answers

vijay

how to save for loop results

Asked by vijay
on 3 Jan 2013

Hello everyone Gud evening and happy new yr i m giving one matlab program below

n=5

for i=1:n

a=magic(i)

end

i want to modify this program such that all the 5 resulting matrices are saved and accessed by name

a1= magic 1 matix

a2= magic 2 matix

a3= magic 3 matix

a4= magic 4 matix

a5= magic 5 matix

would anybody please help me?

  0 Comments

Tags

Products

No products are associated with this question.

2 Answers

Answer by Walter Roberson
on 3 Jan 2013

  2 Comments

vijay
on 3 Jan 2013

thank u very much sir. bt i havnt got the solution from the link given by you.

José-Luis
on 3 Jan 2013

What did you try or which part did you not understand?


Answer by Hello kity on 3 Jan 2013
Edited by Hello kity on 3 Jan 2013

Creat cell array/ or normal matrix

n=5
a=cell(1,5)
for i=1:n
a{i}=magic(i)
end

  0 Comments


Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply today