How to graph irrational functions

I'm trying to graph this equation: k = (s-2)/(-s^2-s+6), but I keep getting errors like "Error using ^ Inputs must be a scalar and a square matrix. To compute elementwise POWER, use POWER (.^) instead."
How do I graph this? Below is the code I'm using
k = [0,50];
s = [-3, 2];
k = (s-2)/(-s^2-s+6);
plot (k,s)

回答 (4 件)

Walter Roberson
Walter Roberson 2017 年 2 月 28 日

0 投票

k = @(s) (s-2) ./ (-s.^2-s+6);
s = linspace(-3, 2);
kv = k(s);
plot(s, kv)
Chad Greene
Chad Greene 2017 年 2 月 28 日

0 投票

You can fix that error by including the . when you multiply or compute the exponent:
k = (s-2)./(-s.^2-s+6);
But nothing will show up, because for the values you provided you're dividing by zero.
Roger Stafford
Roger Stafford 2017 年 2 月 28 日
編集済み: Roger Stafford 2017 年 2 月 28 日

0 投票

I think what you are trying to do is this (it’s just a guess.)
s = linspace(-3,2);
k = -1./(s+3);
plot(s,k)
Note: The fraction (s-2)/(-s^2-s+6) simplifies to -1/(s+3).
Note 2: You will get an infinite value at s = -3 so that point will not appear on the plot.
Note 3: The function you describe is a rational, not an irrational, function!
Brendan Nikola
Brendan Nikola 2017 年 2 月 28 日

0 投票

That's it! Thank-you! I hvae a follow up question. If I wanted to include the jw imaginary axis, how what I write that?

1 件のコメント

Chad Greene
Chad Greene 2017 年 3 月 1 日
You're unlikely to get an answer to any question if the question is written in the answer space of your own question. I recommend starting a new thread for each new question.

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

カテゴリ

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

質問済み:

2017 年 2 月 28 日

コメント済み:

2017 年 3 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by