フィルターのクリア

How do I plot this non-linear function...

4 ビュー (過去 30 日間)
Chris
Chris 2011 年 2 月 20 日
This question is pretty elementary, but I'm new to MATLAB and am having trouble with this. I want two curves, one of r vs. T (which is easy, it's just a fourth power function) and one of r2 vs. T (on the same graph). That's fine, except r2 is r multiplied by some function of T (which will be on the x-axis) that I called k.
T=180:1:360
k=.8823-((T-179)*(.0039))
s=1.1e-2
r=s*(T.^4)
r2=k*s*(T.^4)
plot(T,r,'-k',T,r2)
This doesn't work...This is just an example, but my head still isn't around the matrix interpretation of plotting, so any tips for plotting stuff like this or non-linear functions in general would be appreciated

回答 (2 件)

Matt Fig
Matt Fig 2011 年 2 月 20 日
One minor change will make it work.
T = 180:1:360;
k = .8823-((T-179)*(.0039));
s = 1.1e-2;
r = s*(T.^4);
r2 = k.*s.*(T.^4); % Or r2 = k.*(s*(T.^4)); Or r2=(k*s).*(T.^4);
plot(T,r,'-k',T,r2)
In general, whenever you have two or more vectors and you want their product to be a vector, use element-by-element multiplication (include the dot). Look at a small example:
a = 1:3
b = 5:7
a.*b
The same goes for division and exponentiation.

Matt Tearle
Matt Tearle 2011 年 2 月 20 日
You should be getting an error on the line that defines r2 (before you even get to the plot). As Matt Fig points out, the multiplication there should be .* (element-wise), not *.

カテゴリ

Help Center および File ExchangeDiscrete Data Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by