Pulling specific data from 2 different matrices, and starting a new matrix

4 visualizaciones (últimos 30 días)
I have a global matrix A of 4 column vectors and i've subsequently constructed 2 separate matrices X and Y from the 1st 2 columns of the global matrix. I want to construct a 3rd matrix using info from the 2 matrices X and Y. the statement will read value from X and Y then match these values in the global matrix A and read off the corresponding value from the 3rd column of A. Can someone advise on the best way to tackle this as my if else if statements are not working. Thats as far as ive got up to. Thanks Ernest
A = importdata(filename,delimiterIn,headerlinesIn);
%% Column vectors%%%%
x= A.data(:,1);
y= A.data(:,2)';
u =A.data(:,1:3);
v= A.data(:,4);
%% Matrices%%%%
n= length(A.data);
Mat_x= repmat(x,1,n); % 1 means the first element in the column is repeated in the row then the 2nd element repeated etc
Mat_y= repmat(y,n,1);
%% U population statement
u_rows= n;
u_col= n;
Mat_u= zeros(u_rows,u_col);
for c= 1: u_col
for r= 1:u_rows
if
Mat_u(r,c)= u(r,c)
  1 comentario
Ernest Adisi
Ernest Adisi el 29 de Jul. de 2018
for example
a= randi(10,10,4);
b= repmat(a(:,1),1,10);
c= repmat(a(:,2)',10,1);
for any element of c and any element of b i can go into a and read the corresponding value from the 3rd row of a

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by