フィルターのクリア

Cell matrix

2 ビュー (過去 30 日間)
john
john 2012 年 4 月 30 日
Hi,
I have matrix of size 6x6. And I have numbers and text in it. How can I write zero "0" only from row 3 to 6 and from column 1 to 4. I have this code:
UserData.matrix=cell(6,6);
for i=3:6
for j=1:4
UserData.matrix{i,j}='0';
end;
end;
But I got error:"??? Error using ==> mupadmex Error in MuPAD command: Invalid index [list];
during evaluation of 'matchNonSingletonLHS'"
Can anybody help my?

採用された回答

Thomas
Thomas 2012 年 4 月 30 日
I think you need to do..
UserData.matrix(i,j)={'0'}; % notice where we have parenthesis (indexing) and curly braces for the values
E.g.
% define a cell (6x6)
a={'1' '2' '3' 'hi' '5' '6'; '2' '3' '4' '5' '6' 'the';'1' '2' '3' 'hi' '5' 'new';'1' '2' '3' 'hi' '5' 'world';'1' '2' '3' 'hi' '5' 'welcome';'Where' '2' '3' 'hi' '5' '6';}
a(3:6,1:4)={'0'} % no need of loop

その他の回答 (1 件)

Jan
Jan 2012 年 4 月 30 日
The posted code and the error message do not match. There is no index "list" in the code. Please read the error message again to find out, which line causes the problem. Using the debugger is recommended also:
dbstop if error
Then Matlab stops as soon as the error occurs and you can inspect the current values.

カテゴリ

Help Center および File ExchangeMatrix and Vector Construction についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by