Does somebody know how to plot this function?

I have the exercise to plot this function:
I have to use an anonymous function
That's my code until now:
figure; hold on;
y = @(x) tan(3*x) + 5*x-4;
x = linspace(0,180);
plot(x, y(x) ,'c');
axis([0 180 -100 1000]);
title('Funktion y = tan(3x)+5x-4');
xlabel('x-Werte[°]');
ylabel('Funktionswerte');
But I don't know how to get the parts between the tangent
or if my solution is even the right beginning, can somebody help?

 採用された回答

Voss
Voss 2022 年 5 月 11 日

1 投票

Use tand rather than tan, because the argument 3*x is in degrees rather than radians.
Increase the number of points to see the asymptotes better. Here I've used 1000 points total.
figure; hold on;
y = @(x) tand(3*x) + 5*x-4;
x = linspace(0,180,1000);
plot(x, y(x) ,'c');
axis([0 180 -100 1000]);

7 件のコメント

Sabrina Bitz
Sabrina Bitz 2022 年 5 月 11 日
Thanks a lot!!
Sabrina Bitz
Sabrina Bitz 2022 年 5 月 11 日
There's something missing I realize now: There needs to be space between the tands, what can be seen in the original, how do I get them?
Voss
Voss 2022 年 5 月 11 日
Probably the easiest way to do that is to use fplot instead of plot:
figure; hold on;
y = @(x) tand(3*x) + 5*x-4;
fplot(y,[0 180],'c');
axis([0 180 -100 1000]);
Sabrina Bitz
Sabrina Bitz 2022 年 5 月 11 日
How is it possible with plot? It says specificially plot in the exercise
Voss
Voss 2022 年 5 月 12 日
Including the exact values of x where tan(3x) goes to infinity seems to work ok.
figure; hold on;
y = @(x) tand(3*x) + 5*x-4;
x = sort([linspace(0,180,1000) 30:60:180]);
plot(x, y(x) ,'c');
axis([0 180 -100 1000]);
Sabrina Bitz
Sabrina Bitz 2022 年 5 月 12 日
Thank you!!
Voss
Voss 2022 年 5 月 12 日
You're welcome!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMathematics についてさらに検索

質問済み:

2022 年 5 月 11 日

コメント済み:

2022 年 5 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by