フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Why won't this code generate the graph I need? What am I missing?

1 回表示 (過去 30 日間)
Matthew Lozancich
Matthew Lozancich 2017 年 11 月 3 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Create a vector t of elements with values from 0 to 360 with a spacing of 3.6 degrees. Using the parametric equations, create two vectors x and y that contain x coordinates and y coordinates, respectively.
function generateflower
for t=0:3.6:360
x = ((1 + cosd(5*t))*cosd(t));
y = ((1 + cosd(5*t))*sind(t));
plot(x,y)
end
end

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 11 月 3 日
You are not following the instructions to "create two vectors x and y that contain x coordinates and y coordinates,"
When plot() is asked to plot a single point at a time, there is no line to generate. It only generates a mark if you configure a marker. For example you would have seen something if you had used
plot(x, y, '*')
hold on
  2 件のコメント
Matthew Lozancich
Matthew Lozancich 2017 年 11 月 3 日
Yup I read the instructions way wrong..
function generateflower
x=zeros(1,101);
y=zeros(1,101);
n=1;
for t=0:3.6:360
x(n) = ((1 + cosd(5*t))*cosd(t));
y(n) = ((1 + cosd(5*t))*sind(t));
n=n+1;
plot(x,y,'r--')
end
end
How does this look?
Walter Roberson
Walter Roberson 2017 年 11 月 3 日
Put the plot after the loop.

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by