×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Matrix problem in Matlab

Matrix problem in Matlab

Matrix problem in Matlab

(OP)
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 :)

RE: Matrix problem in Matlab

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)=[]

RE: Matrix problem in Matlab

(OP)
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...

RE: Matrix problem in Matlab

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.

RE: Matrix problem in Matlab

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources