Dividing a scalar by a vector

I understand that in order to divide a scalar, say a, by a vector, say b, I need to use the following syntax: c = a./b. But what if b was defined as [2 0]? The zero in b causes c to go to Inf and this disrupts my plot. Is there a way to get around this?

3 件のコメント

Walter Roberson
Walter Roberson 2016 年 3 月 20 日
What would you like to have happen there?
VENKATESAN SEETHARAMAN
VENKATESAN SEETHARAMAN 2016 年 3 月 20 日
MATLAB generates a completely blank plot. I am assuming the division by 0 is the cause of the blank plot. Please correct me if I am wrong.
Stephen23
Stephen23 2016 年 3 月 20 日
編集済み: Stephen23 2016 年 3 月 20 日
@VENKATESAN SEETHARAMAN: You are wrong. The plot contains exactly one point, this being the finite value that you have given to plot. Here it is:
>> V = 1./[0,2]
V =
Inf 0.5
>> H = plot(V,'xr');
And we can even check the values in the plot:
>> get(H,'Ydata')
ans =
Inf 0.5
So you are wrong that "MATLAB generates a completely blank plot", because it has actually plotted exactly the data that you have given it. You requested a plot of one finite point and that is what you get.

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

回答 (0 件)

カテゴリ

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

質問済み:

2016 年 3 月 20 日

編集済み:

2016 年 3 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by