フィルターのクリア

parametric plot with values of parameter on plot

10 ビュー (過去 30 日間)
Mohsen
Mohsen 2014 年 3 月 18 日
回答済み: mehran 2023 年 9 月 20 日
I want to graph x=f(t) and y=g(t) but I want some sampling of values of t on the graph. Is there an option of plot command or a specialized program for doing this? So for example say x=cos(t), y=sin(t). I want to annotate the graph by putting t=0, t=pi/6, t=pi/4, etc on the graph. Of course this can be done by adding many text boxes to the graph but I was looking for a more automated solution.
  1 件のコメント
Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh 2014 年 3 月 19 日
Oh! Now I see what you're looking for. Unfortunately I don't know about an automated solution, all I can think of, is to write my own code to add annotations or text to the graph! But I don't think if that's gonna be ver usefull and beneficial code for me! :(
Sorry!

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

回答 (2 件)

Mischa Kim
Mischa Kim 2014 年 3 月 19 日
編集済み: Mischa Kim 2014 年 3 月 19 日
Mohsen, would this do (using ticks and tick labels)?
t = -pi:.1:pi;
y = sin(t);
plot(t,y)
set(gca,'XTick',-pi:pi/2:pi)
set(gca,'XTickLabel',{'t=-pi','t=-pi/2','t=0','t=pi/2','t=pi'})
  1 件のコメント
Mohsen
Mohsen 2014 年 3 月 19 日
The labels are to be on the graph, not on the axis. So for example x= cos(t) y= sin(t) will make a circle and on various points of the circle we want to write the value of parameter t. In general x=f(t), y=g(t) and t has a range of values. We want the the t values on the (x,y) plot.

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


mehran
mehran 2023 年 9 月 20 日
t = linspace(0, 10*pi, 500);
x = 3*t.*cos(t);
y = 3*t.*sin(t);
figure(3);
plot(x,y);
hold on;
vec1=1:20:floor(length(t)/2);
vec2=floor(length(t)/2)+1:10:length(t);
vec=[vec1 vec2];
for ii = 1:length(vec)
txt=sprintf('t=%4.2f',t(ii));
text(x(vec(ii)), y(vec(ii)),txt, 'HorizontalAlignment','left');
end
xlabel('x');
ylabel('y');
title('spiral parametric curve with sample parameter values shown')

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by