求解答:matlab中分段函数问题syms u f=-2*u.^4+2*u.^2+u/6+0.3;if u >= (-0.9-f(-0.9)) & u <= (-0.9) g =0.9+u+f(-0.9);else if u>=(-0.9) & u<=1 g=f; else if u>=1 & u<=(1+f(1)) g=1-u-f(1); end

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/28 12:17:59
求解答:matlab中分段函数问题syms u f=-2*u.^4+2*u.^2+u/6+0.3;if u >= (-0.9-f(-0.9)) & u <= (-0.9)    g =0.9+u+f(-0.9);else if u>=(-0.9) & u<=1    g=f;    else if u>=1 & u<=(1+f(1))    g=1-u-f(1);        end
xTn0~kҦfCIzK+6$MB&!t^fi+^MttzM%Z>?2sݠ:egGɫޏdw`~o?mĠ[·:}( .v4Ur].(ꔸ4h#*$W<;,8&K̪e1e./v:M%Eh:t)diӯ5Gh68vG^.趦UZZV2k5gЧ-ImQgAjqXm:-`L0 sX@g0ΰEaLa:uhqDljcfC f#A%a\1A<!3, # 5'1-J6RQ9s]),> 3+˺^cfn+'P''h/9 >ƛdx;;^_wBO{gGo_] z*E򿎍^P4KR4@S8pBGW|*:.(|.uA[a@LZEzCgg+]ZIwJv) ,VŽPsL/^Ra]Aoҿja3JhY|!T3Y9-HL@ڜ#(!oi>#7NtmȠ&,)Ș1ȯri={o;=N,lbB%My%\

求解答:matlab中分段函数问题syms u f=-2*u.^4+2*u.^2+u/6+0.3;if u >= (-0.9-f(-0.9)) & u <= (-0.9) g =0.9+u+f(-0.9);else if u>=(-0.9) & u<=1 g=f; else if u>=1 & u<=(1+f(1)) g=1-u-f(1); end
求解答:matlab中分段函数问题

syms u 

f=-2*u.^4+2*u.^2+u/6+0.3;

if u >= (-0.9-f(-0.9)) & u <= (-0.9)

    g =0.9+u+f(-0.9);

else if u>=(-0.9) & u<=1

    g=f;

    else if u>=1 & u<=(1+f(1))

    g=1-u-f(1);

        end

    end

end

求大神帮忙看看哪里出错了?是分段函数写的不对还是 syms 的缘故?


求解答:matlab中分段函数问题syms u f=-2*u.^4+2*u.^2+u/6+0.3;if u >= (-0.9-f(-0.9)) & u <= (-0.9) g =0.9+u+f(-0.9);else if u>=(-0.9) & u<=1 g=f; else if u>=1 & u<=(1+f(1)) g=1-u-f(1); end
这样就对了:
>> f = @(u) -2*u.^4+2*u.^2+u/6+0.3;
>> g = @(u) (u>= -0.9-f(-0.9) & u <= -0.9).*(0.9 + u+f(-0.9)) + (u>= -0.9 & u<=1).*f(u) + (u>=1 & u<=1+f(1)).*(1-u-f(1))
g = 
    @(u)(u>=-0.9-f(-0.9)&u<=-0.9).*(0.9+u+f(-0.9))+(u>=-0.9&u<=1).*f(u)+(u>=1&u<=1+f(1)).*(1-u-f(1))
>> plot(linspace(-1,1,100),g(linspace(-1,1,100)))