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 Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by