Complex Sinwave to plot

Hello,
I'm asking how can I plot this kind of function ?
I wish to extract its mathematical expression.
I was thinking about creating a triangular wave first and add it to a sinwave ? Would that be possible ?
But I dont know how to start, I've already code on Matlab but I'm a begineer, so can I have some help to plot the triangle first ?

Réponses (1)

Alan Stevens
Alan Stevens le 4 Mar 2021

0 votes

Like this
x = 0:0.1:4.56;
p = zeros(1,numel(x));
q = zeros(1,numel(x));
for i = 1:numel(x)
p(i) = fn(x(i));
q(i) = fn(x(i)+4.56);
end
plot(x,p,'b',x+4.56,q,'k'),grid
xlabel('x'),ylabel('p & q')
legend('p','q')
function h = fn(x)
if x>=0 && x<=4.56
h = 2*sin(2*pi*0.5*x)+1.1042*x;
elseif x>4.56 && x<=9.12
h = 2*sin(2*pi*0.5*(x-0.1151211265955))-1.1042*(x-0.1151211265955) ...
+ 9.9376427230941;
else
h = NaN;
end
end

Catégories

En savoir plus sur Communications Toolbox dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by