Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations SSS148 on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

having trouble putting data into one matrix 2

Status
Not open for further replies.

wolfknighthawk

Aerospace
Jun 13, 2008
3
I am trying to add matrix A and matrix B to matrix C
Here are my example Matrices
A=[5;4;3;2;1];
B=[6;8;7];
This is what I want
C=[5;4;3;2;1;6;8;7]
 
Can't remember what the command is in Matlab, but in Mathcad, it's called Augment

TTFN

FAQ731-376
 
C=[A;B]
 
Thank you IRstuff and Asixth, that will be very helpful.
Here is my code, I forgot to say that I am trying to Augment many files of different sizes togther to make one Mx1 matrix. the files range in size from 5 to 21 in length. this is the part of my code that does not work:
OX(ma:m,1) = NDPSORBIT_OX_m
the rest works, theoretically I thought this would work. can you point out my error please and lead me in the right direction? Thank you very much.


% Loads Data
[PathName, File, s2, srtlist] = UserData;
ma = 1;
for i=1:10
% Gets the Data
[filename] = GetDataMat(File, PathName, i);
% Loads the first file
load (filename)
% 'MxN'
mn = size(Net_array); % Size of the Matrix
% retrieves M % M= number of scans
m = mn(1,1); n = mn(1,2);
% Gets the info wanted from the file's variable
NDPSORBIT_OX_m = Net_array(1:m,2);
% Theoretically grabs the Matrices and concatenates them %into one matrix: this is the part that does not work
OX(ma:m,1) = NDPSORBIT_OX_m
% indexes the length of each matrix and adds the next one to % keep things in order
ma = ma +m
end
 
I figured out what i was doing wrong, I was not indexing the m correctly
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor