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

1 次查看(过去 30 天)
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 个评论
Ernest Adisi
Ernest Adisi 2018-7-29
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

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by