Complex Sinwave to plot

조회 수: 2 (최근 30일)
bigmack
bigmack 2021년 3월 4일
답변: Alan Stevens 2021년 3월 4일
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 ?

답변 (1개)

Alan Stevens
Alan Stevens 2021년 3월 4일
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

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by