Hey Guys, I am currently learning how to use Matlab and I have a problem that I am struggling with. I am struggling to graph the function y = sin^2(t) on the interval t ∈ [0,2π]. Can you please help me this?

5 commentaires

Dyuman Joshi
Dyuman Joshi le 29 Fév 2024
Modifié(e) : Dyuman Joshi le 29 Fév 2024
Please share the code you have written yet and state the issue you are facing.
Voss
Voss le 29 Fév 2024
The syntax for y = sin^2(t) in MATLAB is
y = sin(t).^2
Hope that helps.
Sam Chak
Sam Chak le 29 Fév 2024
First things first, make sure to bookmark the Help Center, and then search for the keyword 'plot'. You will find the relevant information at this URL: https://www.mathworks.com/help/matlab/ref/plot.html.
It's always a good idea to start by searching in the Help Center before seeking technical assistance, unless the problem is highly specific and no relevant examples can be found.
Dakalo
Dakalo le 29 Fév 2024
@Sam Chak Okay thank you. I will make use of it.
Les Beckham
Les Beckham le 29 Fév 2024
If you are just getting started with Matlab, I would highly recommend that you take a couple of hours to go through the free online tutorial: Matlab Onramp

Connectez-vous pour commenter.

 Réponse acceptée

Alexander
Alexander le 29 Fév 2024

0 votes

t = linspace(0,2*pi,1000);
y = sin(t).^2;
plot(t,y);

5 commentaires

Dyuman Joshi
Dyuman Joshi le 29 Fév 2024
Modifié(e) : Dyuman Joshi le 29 Fév 2024
Please don't do obvious homework questions on Answers, when no effort has been shown. This does not help the student, who learns nothing more than to post all of their homework problems on the site, hoping they will find someone willing to do their thinking and work for them. Worse that that, it convinces the next student who comes along to do the same.
If you want to help, then find a way to push the student in the right direction. But posting a complete solution does far more harm than good.
Alexander
Alexander le 29 Fév 2024
To be honest, some of these questions remind me at the time when I got my first PC-Matlab license in the late 80s. But there was no one I can ask, no www and no mailing list. Hence, it took a long time until I got familiar with Matlab, comming from F77. So I'm not as strict with novices and I'm indulge them.
Dakalo
Dakalo le 29 Fév 2024
Thank you, @Alexander. @Dyuman Joshi You're right, I was frustrated because I was trying to figure it out for a long time without reaching any solution. Next time I will make it a point to try reach some form of a solution.
Alexander
Alexander le 29 Fév 2024
Cheers
Sam Chak
Sam Chak le 29 Fév 2024
@Dakalo, Can you enter the code (click this icon ) and run it here (click this icon )?
A grey field will appear so that you can type out the plotting code. You should also learn about labeling and display trick for repeating decimals such as .

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Performance dans Centre d'aide et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by