How to store multiple array. or multidirection array.

1 回表示 (過去 30 日間)
Triveni
Triveni 2015 年 12 月 17 日
コメント済み: Triveni 2015 年 12 月 17 日
p = [15 30 45 60 75 90 75 60 45 30 15 30 45 60 75 90 75 60 45 30];
N1 = 10;
randidx = randi(numel(p), [1 20 N1]);
p = p(randidx);
for k= 1:20
for i = 1:10
a(k)= cosd (p(:,k,i));
b(k)= sind (p(:,k,i));
end
L(:,:,k) = [a(k)*b(k) 0 (a(k))^2;
0 0 b(k);
0 0 0;];
end
I want every i = 1:10 value but i unable to get. How can i store values for p(:,:,1) for 20 L(:,:,k) and p(:,:,2) for 20 L(:,:,k).....and so on...please help me.
  2 件のコメント
Guillaume
Guillaume 2015 年 12 月 17 日
Please learn to format your posts, I'm not going to fix it for you every time. Use the {} Code button to format code and do not put blank lines between each line of code.
It looks like you are happy with the answer I've given in your other question since you're using it here. Common courtesy means you should at the very least accept the answer.
Triveni
Triveni 2015 年 12 月 17 日
Sorry....I have accepted all pending answers....By your small help I've solve it...Lot of thanks. but once again i request you to answer me how to multiply L(:,:,k,i).*M(:,:,k,i); without loop for i=1:N & for k=1:N. or L(:,:,k,:).*M(:,:,k,:)

サインインしてコメントする。

採用された回答

Guillaume
Guillaume 2015 年 12 月 17 日
Why is p a 3d array if the first dimension is only 1?
You can't store a matrix as an element of another matrix. matrix elements are always scalar. You can store a matrix as an element of a cell array:
L{:, :, k} = [a(k)*b(k) 0 a(k)^2;
0 0 b(k);
0 0 0;]
Whether or not that is what you should do I have no idea since you didn't provide any context. Possibly you intended for p to be 2d and L to be a 3d matrix with the elements of that a*b matrix stored as scalars in the 3rd dimension of L.
  1 件のコメント
Triveni
Triveni 2015 年 12 月 17 日
I'm thankful to you. Lot of thanks.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by