Make multiple vectors the same size

I have three vectors, A, B and C.
The second column of A is the value of A, and the first column is time. For B vector is also the same.
I want to multiply the value of A at a specific time by B. The problem is that they are not the same length and I do not have some values at a specific time.
for t=0.5:0.01:1.3
ans(t,2) = A(t,2)*B(t,2)*cos(C(t,2))
end

2 件のコメント

James Tursa
James Tursa 2022 年 10 月 14 日
Are all the desired times contained within the time ranges of all three A, B, and C? If so, you could interpolate.
NA
NA 2022 年 10 月 14 日
Yes. I have values between 0.5 to 1.3.

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

 採用された回答

dpb
dpb 2022 年 10 月 14 日

0 投票

t=0.5:0.01:1.3;
res=interp1(A(:,1),A(:,2),t).*interp1(B(:,1),B(:,2),t).*cos(interp1(C(:,1),C(:,2),t));

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeInterpolation についてさらに検索

タグ

質問済み:

NA
2022 年 10 月 14 日

回答済み:

dpb
2022 年 10 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by