フィルターのクリア

Plot is a straight line when it should be a curve.

2 ビュー (過去 30 日間)
Azairis
Azairis 2019 年 9 月 26 日
コメント済み: Azairis 2019 年 9 月 26 日
%Givens
DetectedAst = 20
Theta = DetectedAst
xnot = 125
xCenter = xnot
radiusCR = 20
AngleB = 42 %(is constant)
k1 = 5
tPath = 9*pi
%set up figure
%plot curve
plot(0,0,'kd', 'markerfacecolor', 'k');
hold on;
ts = linspace (0,tPath);
PathXcoords = 5 * (cosd(45 + AngleB) * (ts + k1 * sind(ts/2)) + ...
sind(45+AngleB) * (ts + 1/k1 * cosd(ts/2)));
PathYcoords = 5 * (sind(45 + AngleB) * (ts + k1 * sind(ts/2))...
- cosd(45+AngleB) * (ts + 1/k1 * cosd(ts/2)));
plot(PathXcoords,PathYcoords,'color',[105 105 105]/255);
hold on;
grid on;
axis equal;
%Change axis limits
PathXMax= 5* (cosd(45 + AngleB) * (tPath + k1 * sind(tPath/2))...
+ sind(45+AngleB) * (tPath + 1/k1 * cosd(tPath/2)));
PathYMax = 5* (sind(45 + AngleB) * (tPath + k1 * sind(tPath/2))...
- cosd(45+AngleB) * (tPath + 1/k1 * cosd(tPath/2)));
axis([0,PathXMax, 0, PathYMax]);
%Graph is supposed to look like:
  2 件のコメント
Ankit
Ankit 2019 年 9 月 26 日
are you sure that AngleB is a constant value?
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 9 月 26 日
It should be a curve
Why?

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

採用された回答

darova
darova 2019 年 9 月 26 日
Look
11Untitled.png
Also i suggest to write more readable code (even if it's longer)
c1 = cosd(45 + AngleB);
s1 = sind(45 + AngleB);
st = sin(ts/2);
ct = cos(ts/2);
x = 5*c1*(ts + k1*st) + 5*s1*(ts + 1/k1*ct);
y = 5*s1*(ts + k1*st) - 5*c1*(ts + 1/k1*ct);
  1 件のコメント
Azairis
Azairis 2019 年 9 月 26 日
Oh, I see now. Thank you for your help!

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

その他の回答 (1 件)

John D'Errico
John D'Errico 2019 年 9 月 26 日
編集済み: John D'Errico 2019 年 9 月 26 日
Is it really a straight line? Seriously? Did you look CAREFULLY at the curve? A PERFECTLY STRAIGHT LINE? (No.) I'll admit that the deviation is small, so you probably did not see it.
It is just not highly curved. For example, consider the term
(ts + 1/k1 * cosd(ts/2)))
ts varies as from 0 to 28.
What is the magnitude of cos(ts/2)? Clearly that cannot exceed +/-1.
Divide that by k1=5?
Now, how does it compare to ts? Essentially, the linear part of that term dominates the nonlinear part, by roughly 100-1.
Basically, your line DOES have curvature. Just not much of it.
If you wish to test my claim, try this:
diff(PathYcoords)./diff(PathXcoords)
Look very carefully at what you see. Is that vector PERFECTLY constant? They would be so if the curve were perfectly a straight line.
Are your parens wrong? That is something we cannot possibly know, because we are given no clue as to what it is that you really need to do. Something is wrong if you expect to see a strongly curved line. But what might be wrong is just your expectation.

カテゴリ

Help Center および File ExchangeNetworks についてさらに検索

タグ

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by