Borrar filtros
Borrar filtros

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

3 visualizaciones (últimos 30 días)
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

Respuesta aceptada

madhan ravi
madhan ravi el 19 de Oct. de 2018
Editada: madhan ravi el 19 de Oct. de 2018
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 comentarios
Areej Nayab
Areej Nayab el 19 de Oct. de 2018
thanku so much, i have done. yes you are right no need to use loop here.
madhan ravi
madhan ravi el 19 de Oct. de 2018
if it is what you were looking for please accept the answer

Iniciar sesión para comentar.

Más respuestas (1)

Image Analyst
Image Analyst el 19 de Oct. de 2018
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.

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by