how to generate repeated function with failure like this in picture?

1 次查看(过去 30 天)
I want to plot this repeating function with this periodic failure. I have plotted this function without this fail. if any one can help, pleassss!
the function i have do to plot the periodic trapizoid is:
function p=fnpw1(omg1)
omg1=mod(omg1,0.1847);
if omg1 <=0.015392
%p=4.43;
p=4+(0.43*(omg1)/0.015392);
elseif omg1>0.015392 && omg1<0.030784
p=4+(0.43);
elseif omg1>=0.030784 && omg1<0.046176
p=4+(-27.93659*(omg1)+1.29);
elseif omg1>=0.046176
p=4;
end

采纳的回答

Ibrahim A. Shaaban
Ibrahim A. Shaaban 2021-10-8
I have tried to solve it again, i think this code has solved it
function I =fnpwtf3(omg1)
omg2=mod(omg1,2*pi) ;
omg1=mod(omg1,0.1847) ;
safe_cond_up =omg1 <=0.015392 ;
safe_cond_st = omg1>0.015392 & omg1<0.030784;
safe_cond_dn = omg1>=0.030784 & omg1<0.046176;
safe_cond_msc=omg1>=0.046176 ;
p_up=4+(0.43*(omg1)/0.015392);
p_st=4+(0.43);
p_dn=4+(-27.93659*(omg1)+1.29);
p_msc=4 ;
fail_cond = omg2>0.7391982716 & omg2<=1.524596435;
fail_cond_dn1 =omg1 <=0.04619989196 ;
fail_cond_st1 = omg1>0.04619989196 & omg1<=0.1847995678;
fail_cond_up1 = omg1>0.1847995678 & omg1<=0.2001995318;
fail_cond_st2 = omg1>0.2001995318 & omg1<=0.2155994958;
fail_cond_dn2 = omg1>0.2155994958 & omg1<=0.2309994598;
fail_cond_st3 = omg1>0.2309994598 & omg1<=0.3695991356;
fail_cond_up2 = omg1>0.3695991356 & omg1<=0.3849990996;
fail_cond_st4 = omg1>0.3849990996 & omg1<=0.4003990636;
fail_cond_dn3 = omg1>0.4003990636 & omg1<=0.4157990276;
fail_cond_st5 = omg1>0.4157990276 & omg1<=0.5543987034;
fail_cond_up3 = omg1>0.5543987034 & omg1<=0.5697986674;
fail_cond_st6 = omg1>0.5697986674 & omg1<=0.5851986314;
fail_cond_dn4 = omg1>0.5851986314 & omg1<=0.6005985954;
fail_cond_st7 = omg1>0.6005985954 & omg1<=0.7391982712;
fail_cond_up4 = omg1>0.7391982712 & omg1<=0.7853981634;
pf_dn1=(-21.64507226)*(omg1)+4;
pf_st1=3;
pf_up1=(27.92214318*(omg1))-2.159999994;
pf_st2=3.43 ;
pf_dn2=(-27.92214319)*(omg1)+9.449999994;
pf_st3=3;
pf_up2=(27.92214319*(omg1))-7.319999989;
pf_st4=3.43 ;
pf_dn3=(-27.92214319)*(omg1)+14.60999999;
pf_st5=3;
pf_up3=(27.92214319*(omg1))-12.47999998;
pf_st6=3.43 ;
pf_dn4=(-27.92214319)*(omg1)+19.76999998;
pf_st7=3;
pf_up4=(21.64507215*(omg1))-12.99999991;
S=p_up.*(safe_cond_up) + p_st .*(safe_cond_st) + p_dn.*(safe_cond_dn)+ p_msc.*(safe_cond_msc) ;
F= pf_dn1.*(fail_cond_dn1) + pf_st1 .*(fail_cond_st1) + pf_up1.*(fail_cond_up1)...
+ pf_st2 .*(fail_cond_st2) +pf_dn2.*(fail_cond_dn2)+ pf_st3 .*(fail_cond_st3)...
+ pf_up2.*(fail_cond_up2)+ pf_st4 .*(fail_cond_st4) +pf_dn3.*(fail_cond_dn3)+ pf_st5 .*(fail_cond_st5)...
+ pf_up3.*(fail_cond_up3)+ pf_st6 .*(fail_cond_st6) +pf_dn4.*(fail_cond_dn4)+ pf_st7 .*(fail_cond_st7)...
+pf_up4.*(fail_cond_up4);
I=S.*not(fail_cond)+ F.*(fail_cond) ;
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differential Equations 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by