How to Assign vectors to each dynamic variable name?

조회 수: 8(최근 30일)
Vinay Killamsetty
Vinay Killamsetty 2019년 9월 25일
댓글: Guillaume 2019년 9월 25일
Firstly I want to create variable names like z1,z2,..,Zn with n decided by the user
I have an array A of size n*n
I want to assign each row of the array A to each variable
Z1 should contain 1st column of A
Z2 must contain 2nd column of A
Can anyone advice how to do this with some simple method.

채택된 답변

Jan
Jan 2019년 9월 25일
Don't do this.
Hiding an index in the name of variables is a bad idea. Use arrays instead and real indices. Having a matrix is effecient already. Using A(:, k) is much smarter and faster than creating a bunch of variables called A<k>.
This topic is discussed almost every day and a typicial problem of beginners.
  댓글 수: 4
Guillaume
Guillaume 2019년 9월 25일
I tried to do something and it didn't work... so instead of asking how to do something you're asking how to do something else entirely which will not help one bit with the original problem.

댓글을 달려면 로그인하십시오.

추가 답변(0개)

제품


릴리스

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by