Graphing the sine graph

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 Commenti

Dyuman Joshi
Dyuman Joshi il 29 Feb 2024
Modificato: Dyuman Joshi il 29 Feb 2024
Please share the code you have written yet and state the issue you are facing.
The syntax for y = sin^2(t) in MATLAB is
y = sin(t).^2
Hope that helps.
Sam Chak
Sam Chak il 29 Feb 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 il 29 Feb 2024
@Sam Chak Okay thank you. I will make use of it.
Les Beckham
Les Beckham il 29 Feb 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

Accedi per commentare.

 Risposta accettata

Alexander
Alexander il 29 Feb 2024
t = linspace(0,2*pi,1000);
y = sin(t).^2;
plot(t,y);

5 Commenti

Dyuman Joshi
Dyuman Joshi il 29 Feb 2024
Modificato: Dyuman Joshi il 29 Feb 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 il 29 Feb 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 il 29 Feb 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 il 29 Feb 2024
Cheers
@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 .

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Graphics Performance in Centro assistenza e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by