how can i display b(i,j) matrix.i have attached the code i am working with.

2 次查看(过去 30 天)
clear all; a=[1,2,3,4;4,3,2,3]; for i=1,size(a,1) for j=1,size(a,2) b(i,j)=a(i,j) disp(b) // this is not giving the out i need end end

采纳的回答

madhan ravi
madhan ravi 2018-10-19
编辑:madhan ravi 2018-10-19
a=[1,2,3,4;4,3,2,3];
[m,n]=size(a)
b = zeros(m,n) % pre-allocate for speed
for i=1:m % not , should be :
for j=1:n
b(i,j)=a(i,j);
% disp(b) % this is not giving the out i need e
end
end
disp(b)
  5 个评论

请先登录,再进行评论。

更多回答(1 个)

Image Analyst
Image Analyst 2018-10-19
Try double clicking b in the workspace panel to bring it up in the variable editor. Or you can put the cursor next to b and type control-d to bring it up in the variable editor.
Also, please read this link: http://www.mathworks.com/matlabcentral/answers/13205#answer_18099 and fix your post.

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by