フィルターのクリア

How to plot thisfunction?

1 回表示 (過去 30 日間)
Yagnaseni Roy
Yagnaseni Roy 2012 年 5 月 6 日
The function to be plotted is:
50*(y*(28.065*cos(60[1/s]*t+0.2094395101999999[1/m]*x)+22.7058*cos(2*(60[1/s]*t+0.2094395101999999[1/m]*x))+15.1368*cos(3*(60[1/s]*t+0.2094395101999999[1/m]*x))+7.014*cos(4*(60[1/s]*t+0.2094395101999999[1/m]*x)))/1[m])[m/s]
As you can see, its a function of three variables, x,y and t.....
However I need it to vary only between 0 to 30 w.r.t x...and the y and t values can be anything...what is the format of the code to be used?
  1 件のコメント
Walter Roberson
Walter Roberson 2012 年 5 月 6 日
First you rewrite the expression in terms of MATLAB operations. In particular, in MATLAB, [] is used for building arrays, and is not an arithmetic operator.

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

採用された回答

the cyclist
the cyclist 2012 年 5 月 6 日
First, as Walter mentions, you need to rewrite the definition of your function in MATLAB syntax.
Here, I assumed that you wanted x,v, and t on a simple grid, and plot them for all combinations.
[Also, it looks like the terms you have in square brackets are just units, so I simply took them out.]
xvec = 1:10;
yvec = 1:20;
tvec = 1:5;
[x,y,t] = ndgrid(xvec,yvec,tvec);
f = 50*(y.*(28.065*cos(60*t+0.2094395101999999*x)+22.7058*cos(2*(60*t+0.2094395101999999*x))+15.1368*cos(3*(60*t+0.2094395101999999*x))+7.014*cos(4*(60*t+0.2094395101999999*x)))/1);
But now you have a function three variables, so you want a plot over a four-dimensional space: (x,y,t,f).
What kind of plot are you hoping to see from that?
EDIT: Here's a version of the plotting that selects just one value of y and t, as you suggest:
xvec = 0.1:0.1:5;
yvec = 10;
tvec = 1;
[x,y,t] = ndgrid(xvec,yvec,tvec);
f = 50*(y.*(28.065*cos(60*t+0.2094395101999999*x)+22.7058*cos(2*(60*t+0.2094395101999999*x))+15.1368*cos(3*(60*t+0.2094395101999999*x))+7.014*cos(4*(60*t+0.2094395101999999*x)))/1);
figure
plot(x,f)
  2 件のコメント
Yagnaseni Roy
Yagnaseni Roy 2012 年 5 月 6 日
Ya, you're right that the terms in the square brackets are only units and so u can just take them out.
The y and t values could be fixed at particular values, say y=10 and t=1....and now we can plot f vs x.
the cyclist
the cyclist 2012 年 5 月 7 日
I edited my answer in response to the comment.

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

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by