Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Matrix problem in Matlab

Status
Not open for further replies.

manutdevil

Computer
Mar 15, 2006
10
0
0
MY
im new to matlab and i hope you pros can solve my problem.
i have 2 different matrix. Matrix A is 4500X8 and matrix B is 4000X8.

is there anyway i can change the size of the matrix to 4230X1???



thanx to all of you in advance :)
 
Replies continue below

Recommended for you

Rows or columns of a matrix can be deleted by setting the elements equal to the empty matrix

i.e.

% Make a simple matrix
a=rand(3,5)

% Copy matrix and then display and remove the second row
b = a;
b(2,:)
b(2,:) = []

% Copy matrix and then remove the display and third and fourth columns
c = a;
c:),3:4)
c:),3:4) = []


A:),2:end)=[]
 
by doing the copying and removing, doesnt it mean that i will lose part of my data??
is there anyway i wont lose my data and at the same time reshape it??

thanx for ur reply man...
 
I'm not sure what you are asking, because there is no way you can take the data in a 4500 x 8 matrix and put it in the vector of 4230 x 1. If you tell me what rows/cols you want in the 4230 x 1, I can tell you want you need.
 
You can make any matrix size you would like. Say you have 2 vectors A, and B being a 4500 x 8 and a 4000 x 8 respectively.

You can create a matrix of any size using 'ones()' and 'zeros()' depending on what you would like to do.

For example.

vec = zeros( r, c );

This creates a vector 'vec' with rows 'r' and columns 'c' filled with the number '0.' This would be used in a situation where you would like to ADD the new data to the matrix.

vec2 = ones( r, c);

This creates a vector 'vec2' with rows 'r' and columns 'c' filled with the number '1.' This would be used if you wanted to multiply the data to the new matrix.

SECOND THOUGHT...

Try this....

vec = a( row, col )

with row you can obviously define what you would like to take out. For example, row = 1:4230...etc etc

if 'A' is a 4500 x 8 vector then....

vec = A( 1:4230, 3 )

would store all of the rows from 1 to 4230 in the 3rd column in a vector of 4230 x 1
 
Status
Not open for further replies.
Back
Top