Creating a two matrices from 2 existing matrices according to a rule
3 views (last 30 days)
Show older comments
Hi all,
I am new to matlab and I have been trying to create a rule for the past couple of days, unfortunately unsuccessful I hope that someone here would be able to help me.
Here is the problem:
I have two matrices Y ( 1 column vector with 10 000 entries) and X (matrix with 4 columns, 10 000 entries in each). I want to create new matrix Y and X according to the following rule, Matrix X should contain the same 4 columns but only 50 observations, and the rule: it should contain the first 50 observations in absolute value from column 3 and the corresponding elements (to the observations in column 3) from column 1, 2 and 4. It should take also the corresponding elements of vector Y to the first 50 observations in absolute value in column 3 of X. And it should save them in new matrices Y1 and X1. And here is the most challenging part: It should do this 200 times increasing the number of observations each time by 50 (meaning the first 50 in absolute value in column 3 in X + the second 50 in absolute value in column X, etc.)
I am really puzzled how to do this and I hope somebody can help me.
Thank you all for your help and time!
1 Comment
Accepted Answer
Image Analyst
on 12 May 2012
What does this mean: "the first 50 observations in absolute value"? Do you mean that you just simply take the absolute value of the column 3, like this:
first50Col3Values = abs(X(1:50, 3));
and I don't understand your most challenging part, aren't you simply taking abs(X(51:100, 3)), abs(X(101:150, 3)) and so on, two hundred times? What's so hard about that?
More Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!