Define a series of matrices
9 次查看(过去 30 天)
显示 更早的评论
How do I define the next series of matrices
A=[0,1;sigma,0].
where
sigma=[-5:0.01:-4]
And I want the label to be as follows
A1=[0,1;sigma(1),0]
采纳的回答
Stephen23
2020-3-21
编辑:Stephen23
2020-3-21
Using numbered variables is not going to be neat or efficient. The MATLAB approach would be to use one array, e.g.:
sigma = -5:0.01:-4; % the square brackets are superfluous
N = numel(sigma);
A = [zeros(N,1),ones(N,1),sigma(:),zeros(N,1)]
Each row of A is one of your output vectors, e.g.:
A(1,:)
2 个评论
Walter Roberson
2020-3-21
sigma = -5:0.01:-4; % the square brackets are superfluous
N = numel(sigma);
A = [zeros(1,1,N),ones(1,1,N); reshape(sigma,1,1,N), zeros(1,1,N)];
A is now a 2 x 2 x 101 array. A(:,:,37) would correspond to what you were hoping to see as a separate variable A37
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!