t = linspace(0, 4*pi);
x = @(t)(4+sin(a*t))*cos(3*t);
y = @(t) (4+sin(a*t))*sin(3*t);
z = @(t) cos(3*t);
How is it possible to plot this function?

 채택된 답변

Star Strider
Star Strider 2017년 3월 25일

1 개 추천

I had to supply a value for ‘a’, assuming it is a scalar.
This works:
t = linspace(0, 4*pi);
a = 1; % Guess The Value Of ‘a’
x = @(t)(4+sin(a*t)).*cos(3*t);
y = @(t) (4+sin(a*t)).*sin(3*t);
z = @(t) cos(3*t);
figure(1)
plot3(x(t), y(t), z(t))
grid on
You need to vectorize your functions to do element-wise operations (replacing ‘*’ with ‘.*’). See the documentation on Array vs. Matrix Operations for details.

댓글 수: 2

Jente Marien
Jente Marien 2017년 3월 25일
Forgot to mention a = 62
Thanks!
Star Strider
Star Strider 2017년 3월 25일
Since ‘a’ is a scalar, this will work.
My pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

질문:

2017년 3월 25일

댓글:

2017년 3월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by