How do I correctly enter the function sin^2 *(2*pi*f*t)?

After I set t and f equal to a value how do u solve the function?

2 Comments

f=100;
t=0:0.1:10;
X=sin(2*pi*f*t).*sin(2*pi*f*t);
plot(t,X);
You have to give a range of t values to plot this graph by this command t = initial value : incremental value : final value;
In other words by this command we have created a vector t that consists of all values between 0 to 10.

Sign in to comment.

Answers (5)

sin(2 .* pi .* f .* t) .^ 2

2 Comments

Thanks! So is the next one plotted correctly?
X = 2.*sin(2.*pi.*f.*t).*cos(2.*pi.*f.*t)
?
That looks okay. You would then
plot(t, X)

Sign in to comment.

Plot(t, x)

1 Comment

MATLAB is case sensitive now so Plot() would only be accepted on old versions of MATLAB. Exact dates are not coming to mind... I want to say since about r2006a.

Sign in to comment.

How to command in matlab? Pls solve my problem. Thank you

3 Comments

Sorry, that is not notation I recognize. {} is set notation, and there appears to be the word 'set' before it, so the notation appears to have something to do with sets. However I am not familiar with any meaning for superscript n on a set, or for subscript j for a set. I can imagine that there could potentially be meaning for assigning value 1 to be associated with elements of a set, but the = is the wrong size and position to be assigning to the whole set. It almost appears as if the subscript is 'j=1', but when I look at the overall equation, it seems to me to be much more likely that j is intended to indicate sqrt(-1) and the set has to do with roots of unity.
N =[]; %initialising an array
for j = 1:n %loop to get n different values of x
x = 4*(cos((0.5*sqrt(-1)*pi)/(n+1)).^2);
N = [N x]; %appending values of x in initialised array
end
%Here, i have assumed set as an array of values.
%And we need to provide value of n too.
The x calculation here does not depend on the for loop variable j

Sign in to comment.

) Given a vector, t, of length n, write down the MATLAB expressions that will correctly compute the following:
a) ln(2 + t + t 2 )
b) e t (1 + sin(2t))
c) cos 2 (t) + sin 2 (t)
d) sec 2 (t) + cot(t)
- 1 - Test that your solution works for t = 1:0.5:4
- Plot the expressions -
Label the plotted figure with the following
o Title ( i.e.: Plot of ln(2 + t + t 2 ) )
o Axis
o Figure caption (your name and ID)

4 Comments

I am pretty sure this is not a solution to the question that Joshua Foster asked.
i need halp for this Q if anyone can help me
As Walter stated this isn't an answer to the original question. In addition, this sounds like a homework assignment. If it is, show us the code you've written to try to solve the problem and ask a specific question about where you're having difficulty and we may be able to provide some guidance.
If you aren't sure where to start because you're not familiar with how to write MATLAB code, I suggest you start with the MATLAB Onramp tutorial (https://www.mathworks.com/support/learn-with-matlab-tutorials.html) to quickly learn the essentials of MATLAB.
If you aren't sure where to start because you're not familiar with the mathematics you'll need to solve the problem, I recommend asking your professor and/or teaching assistant for help.

Sign in to comment.

(√z2+(xele −x2)/c how do i wirte this in matlab

1 Comment

(sqrt(z2) + (xele - x2))/c
or possibly
(sqrt(z2 + (xele - x2)))/c
or possibly
sqrt(z2 + (xele - x2)/c)
depending on how far the square root is intended to extend.

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Asked:

on 2 Sep 2017

Commented:

on 1 Apr 2021

Community Treasure Hunt

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

Start Hunting!