I'm plotting sin(theta) and theta, and that's working. But I'm also trying to plot the error between the two as a percentage, and plot that against theta. The second plot shows up, but there's no data. Please let me know if you can reproduce, and if I'm doing something wrong.
Also, how can I print out the values of the pct series so I can see the actual numbers?
Thanks.
theta = 0:0.02:1;
y = sin(theta);
plot(theta, y, theta, theta)
grid
pct = 100 - (100 * (theta - y) / y);
plot(theta, pct)
grid

 採用された回答

VBBV
VBBV 2021 年 5 月 3 日

0 投票

%if true
theta = 0:0.02:1;
y = sin(theta);
figure(1)
plot(theta, y, theta, theta)
grid
pct = 100 - (100 * (theta - y)./ y);
figure(2)
plot(theta, pct)
grid
Try this For second figure, use element wise division operator

その他の回答 (1 件)

David Hill
David Hill 2021 年 5 月 3 日

1 投票

theta = 0:0.02:1;
y = sin(theta);
plot(theta, y, theta, 1- (theta - y)./y);%need ./ also to keep it the same scale chose 1 instead of 100

カテゴリ

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

製品

リリース

R2021a

タグ

質問済み:

2021 年 5 月 2 日

回答済み:

2021 年 5 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by