How to plot a combination of product and devision of some vectors

5 ビュー (過去 30 日間)
Mojtaba Mohareri
Mojtaba Mohareri 2020 年 1 月 20 日
コメント済み: Mojtaba Mohareri 2020 年 1 月 21 日
I have three (1 in 1000) vectors x, y and z. I want to plot this function x(t)y(t)/z(t) for t=1/1000,2/1000, ... ,1.
I was wondering if someone could help me about it.
Thanks in advance.

採用された回答

Sindar
Sindar 2020 年 1 月 20 日
Set up an example problem:
x=rand(1,1000);
y=rand(1,1000);
z=rand(1,1000);
t = [1:1000]/1000;
% calculate your function
f = x.*y./z;
plot(t,f)
Note that .* and ./ are elementwise multiplication and division, performing your function on each element separately and returning an array of the same size.
(note: if you have vectors x,y,z, then you can't index by fractions. But, it doesn't sound like you actually need to)
  1 件のコメント
Mojtaba Mohareri
Mojtaba Mohareri 2020 年 1 月 21 日
I understood. Thank you very much for your help and answer.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by