Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Having problem inserting and accessing the values from that cell array

1 回表示 (過去 30 日間)
Sandeep Nair
Sandeep Nair 2018 年 11 月 14 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Am trying to insert a 3 matrix of m x n size into a cell array by using a loop statement like
for i=1:3
a{i} = {M }; (M is the matrix which comes after calculation inside loop and am storing the calculation inside M and then transferring to cell )
end
Now i want to access the values such that
a{1,1} will have the mxn double matrix in it
but currently within the a cell it is creating one more cell of 1x1 and then inside that it is creating the mxn matrix
I want to directly insert the values in a{1,1},a{1,2},a{1,3} instead of a{1,1}{1,1} , a{1,1}{1,2} , a{1,1}{1,3}

回答 (1 件)

KSSV
KSSV 2018 年 11 月 14 日
編集済み: KSSV 2018 年 11 月 14 日
a = cell(3,3) ;
M = rand(3) ;
for i = 1:3
for j = 1:3
a{i,j} = M ;
end
end

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by