Vector operatin in Matlab
2 views (last 30 days)
Show older comments
Hi,
I have to programme a proccess but I don't know how to do it.
I have a vector called 'x' :
X= 1 2 3 4 5 6
On the other hand, another called y (related with x).
Y= 0.1 0. 3 0.4 0.8 0.3 0.5
Then, I have another table that also is from 1 to 6 (the x vector is the same). But this table has only numbers in the 5, 6 and 7th position.
Y1= - - - 0.2323 0.25656 0.8
I need to create one new vector that multiply the y values with the y1 but I don't know how to do it in Matlab.
Greetings and thanks a lot in advance,
2 Comments
Jan
on 31 Jul 2012
The vector does not have a 7th position, because it has 6 elements only.
Please explain this sentence again, what are you needing exactly. "Creating a new vector that multiply y with y1" is not sufficient to understand, what you want to achieve. I cannot imagine, what the "-" in the vector should be.
Accepted Answer
Andrei Bobrov
on 30 Jul 2012
Edited: Andrei Bobrov
on 1 Aug 2012
Y= [0.1 0.3 0.4 0.8 0.3 0.5];
Y1 = [0.2323 0.25656 0.8];
out = [zeros(1,numel(Y1)-numel(Y)),Y].*[zeros(1,numel(Y)-numel(Y1)),Y1];
6 Comments
More Answers (1)
See Also
Categories
Find more on Logical 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!