フィルターのクリア

How to approach this type of question in matlab?

39 ビュー (過去 30 日間)
Mohit
Mohit 2024 年 8 月 3 日 18:50
コメント済み: Image Analyst 2024 年 8 月 3 日 21:11
A ship travels on a straight line course described by y = (2005x)/6, where distances are measured in kilometers. The ship starts when x = -20 and ends when x = 40. Calculate the distance at closest approach to a lighthouse located at the coordinate origin (0,0). Do not solve this using a plot.
  2 件のコメント
Mohit
Mohit 2024 年 8 月 3 日 19:13
*y=200-5x/6
Sam Chak
Sam Chak 2024 年 8 月 3 日 19:40
Mohit, do not express the equation using implied multiplication or implied division. Use standard computing notation for math operators when expressing an inline equation.
Because we don't know whether the path trajectory equation is
200 - 5*(x/6)
Or
(200 - 5*x)/6.

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

回答 (2 件)

Image Analyst
Image Analyst 2024 年 8 月 3 日 18:59
編集済み: Image Analyst 2024 年 8 月 3 日 19:03
This looks like a homework problem. If you have any questions ask your instructor or read the link below to get started:
Obviously, if it is homework, we can't give you the full solution because you're not allowed to turn in our code as your own.
Hints: linspace to define x, and be sure to use enough points to get good resolution, like ten thousand or so. Use sqrt to compute distance of (x,y) to (0,0) origin. Use min to find the minimum distance and index for that distance.
  4 件のコメント
Torsten
Torsten 2024 年 8 月 3 日 19:29
min: x^2 + y^2 = x^2 + (200-5*x/6)^2
Do you know how to compute the vertex of this parabola ?
Image Analyst
Image Analyst 2024 年 8 月 3 日 21:11
@Mohit using your updated/corrected formula
x = linspace(-10, 30, 20000);
y = 200 - 5 * x / 6;
D = sqrt(x.^2 + y.^2);
min_dist = min(D)
min_dist = 177.5528
or maybe
x = linspace(-10, 30, 20000);
y = (200 - 5 * x) / 6;
D = sqrt(x.^2 + y.^2);
[min_dist, indexOfClosest] = min(D)
min_dist = 25.6074
indexOfClosest = 13197
plot(x, y, 'b-', 'LineWidth', 2)
grid on;
line([0, x(indexOfClosest)], [0, y(indexOfClosest)], 'Color', 'r', 'LineWidth', 2)
axis equal
Still not exactly sure what the formula is. Please use parentheses to make it unambiguous.

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


Sam Chak
Sam Chak 2024 年 8 月 3 日 19:58
The distance of the ship at the closest approach to a lighthouse should be the perpendicular distance from the lighthouse (0, 0) to the straight line trajectory of the ship.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by