Hi, I'd like to know if I could create some matricies from array elements, for example, if I have four arrays of dimension n by 1, can I then create n matricies by defining something like M(i)=[array1(i),array2(i);array3(i),array4(i)] and running a loop over i? Any help would be appreciated. Thanks. Edit: Thanks for answering sixwwwwww, I didn't know you could make a matrix of arrays, but I was kind of hoping to do it the other way round (an array of matricies). My goal is to put the matricies into an equation and then plot the resulting elements, so I was hoping to be able to do something like: define a set of n matricies using nth elements of my arrays, put these n matrices into my equation to obtain another set of n matrices, then plot the resulting matrix elements against some function of n. Is there any way I could do this?

 채택된 답변

sixwwwwww
sixwwwwww 2013년 10월 23일

0 개 추천

Dear James. you dont need loop for this you can do it like this:
array1 = rand(10, 1);
array2 = rand(10, 1) * 2;
array3 = rand(10, 1) * 3;
array4 = rand(10, 1) * 4;
M = [array1 array2 array3 array4];
I hope it is what you need. Good luck!

댓글 수: 3

Dear James, you can make an array of matrices using cell array as follows:
for x = 1:length(array1)
M{x} = [array1(x) array2(x) array3(x) array4(x)];
end
In this cell array each cell contain a separate matrix formed by four separate arrays. Is it what you require?
James
James 2013년 10월 28일
Yes, this is more what I was looking for, now I've got a nice little script for effective permittivities extraction from COMSOL data, thanks for the help :)
sixwwwwww
sixwwwwww 2013년 10월 28일
You are welcome

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

질문:

2013년 10월 23일

댓글:

2013년 10월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by