フィルターのクリア

Vector operatin in Matlab

1 回表示 (過去 30 日間)
klipya
klipya 2012 年 7 月 30 日
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 件のコメント
Jan
Jan 2012 年 7 月 31 日
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.
klipya
klipya 2012 年 8 月 1 日
編集済み: klipya 2012 年 8 月 1 日
Thanks Jan for your reply. Yes, you are right, it only has 6 elements, sorry. The '-' element, mean that there aren't any value there. So, for example: I need that the code multiply, on one hand, 6(x)*0.5(y) and, on the other hand, also 6*0.8(y1). And then I need multiply the result of both elements. On the first position I need:
1(x)*0.1(y1) and 1*nothing (becaure there aren't any value, so I need a '0' result).
Why I'm doing this? Because I have one vector called x, one another called y and the last one, y1. And I need that the y1 don't do 1*0.2323 because it's not on the same position (it has to be 1* 0 because there aren't any position).
I don't know if I'm explaining well. I hope yes! Thanks a lot! ;)
Pd) I can't not do it if the size of the vectors are different?

サインインしてコメントする。

採用された回答

Andrei Bobrov
Andrei Bobrov 2012 年 7 月 30 日
編集済み: Andrei Bobrov 2012 年 8 月 1 日
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 件のコメント
Andrei Bobrov
Andrei Bobrov 2012 年 8 月 2 日
Please give simple numeric example
klipya
klipya 2012 年 8 月 3 日
This is what I've done:
graf=0; for p=(101:180) graf(p)=out1_c; end for p=(171:240) graf(p)=out2_c; end
And I create the document Y1 with O in the places that I don't need and it works.

サインインしてコメントする。

その他の回答 (1 件)

venkat vasu
venkat vasu 2012 年 7 月 30 日

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by