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

조회 수: 3 (최근 30일)
Ernest Adisi
Ernest Adisi 2018년 7월 29일
댓글: Ernest Adisi 2018년 7월 29일
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에서 Linear Algebra에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by