Cell matrix
2 次查看(过去 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?
0 个评论
采纳的回答
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
0 个评论
更多回答(1 个)
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.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!