hi everyone , i need help to make this , thank u

i hava two matrix 2x8
A=2*ones(2,8)
B=3*ones(2,8)
what i need is to access on
1) on each column of matrix A so i need to get out a column vector 2x1 for 8 times to use it in a certain iteration
2) and then on each column of matrix B the same
all of this in the same iteration inside a loop
because if the two matrix are 1x8 it will be easy with two for i=1:8 and j=1:8 (in this case he gave me (1,1) and (1,2) ............ 1,8) then (2,1) ,(2,2) ................. (2,8)) but in this case i need to extract not an element but a column vector.
thank you

9 comentarios

madhan ravi
madhan ravi el 7 de Abr. de 2019
Editada: madhan ravi el 7 de Abr. de 2019
in this case he gave me
who??, homework
mina massoud
mina massoud el 7 de Abr. de 2019
iam trying to do somthing in matlab , but i can't do this
can u help me plz
thank u
madhan ravi
madhan ravi el 7 de Abr. de 2019
Editada: madhan ravi el 7 de Abr. de 2019
2*ones(2,1,8)
mina massoud
mina massoud el 7 de Abr. de 2019
and how can i select from the second matrix B
madhan ravi
madhan ravi el 7 de Abr. de 2019
Editada: madhan ravi el 7 de Abr. de 2019
Do the same thing.
mina massoud
mina massoud el 7 de Abr. de 2019
can i make an array matrix 2x1 where each element is a matrix 2x8
madhan ravi
madhan ravi el 7 de Abr. de 2019
What do you mean ?, illustrate with an example
Image Analyst
Image Analyst el 7 de Abr. de 2019
Editada: Image Analyst el 7 de Abr. de 2019
Example would be good. Plus explain what "access on" means. Do you simple mean
[rows, columns] = size(A);
for col = 1 : columns
thisColA = A(:, col) % Extract column from A.
thisColB = B(:, col) % Extract column from B.
% Now do something .....
end
mina massoud
mina massoud el 7 de Abr. de 2019
clear all
clc
A=2*ones(2,8)
B=3*ones(2,8)
for i=1:2
for j=1:8
C=
end
end
i want to creat a matrix C 2x1 that the
1) first elementi is a matrix that contain A (2x8)
2) second element is a matrix that contain B(2x8)
thank u

Iniciar sesión para comentar.

 Respuesta aceptada

madhan ravi
madhan ravi el 7 de Abr. de 2019
No loops needed:
C=permute(reshape([A;B].',size(A,2),size(A,1),[]),[2,1,3]) % C(:,:,1) contains A and 2 B

3 comentarios

If you want to use a loop then:
[m,n]=size(A);
C = cell(m,1);
AB=[A;B];
for ii=1:2
C{ii} = AB(ii*m-(m-1):ii*m,:);
end
% celldisp(C)
mina massoud
mina massoud el 7 de Abr. de 2019
thank u very much
that what i need
u r the best
mina massoud
mina massoud el 7 de Abr. de 2019
can i ask u another question
if i have two matrix and i want to chose the minimum value of each element from the two matrix so i want two make a comparisione for each element and take the smal value and put it in another matrix

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Etiquetas

Preguntada:

el 7 de Abr. de 2019

Comentada:

el 7 de Abr. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by