piecewise function only plotting half?

Hello, I am very new to matlab and am trying to graph a function of mutiple piecewise conditions. However, it only seems to be graphing up to x=5 (I need it tot graph to x=10). I've tinkered with it, and it seems to only be count the a= piecewise, none of the others. Can anybody see why that is? thank you

댓글 수: 4

dpb
dpb 2019년 8월 29일
Not without the code, no...
Raphael Hatami
Raphael Hatami 2019년 8월 30일
편집: dpb 2019년 8월 30일
the code is in the picture, here it is copiable:
function u = displacement(x)
syms x
a = piecewise(x>0,(x-0).^4,x<=0,0)
b = piecewise(x>5,(x-5).^4,x<=5,0)
c = piecewise(x>8,(x-8).^3,x<=8,0)
d = piecewise(x>7,(x-7).^2,x<=7,0)
x = linspace(5,15,100)
u = (-5/6)*(a-b)+(15/6)*c+75*d+(57/6)*x.^3-238.25*x
fplot(x,u,'k--')
title('Displacement vs. Distance')
xlabel('Distance [ft]')
ylabel('Displacement [ft]')
fplot(u, [min(x), max(x)])
Raphael Hatami
Raphael Hatami 2019년 8월 31일
thanks Walter, this worked!

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

제품

태그

질문:

2019년 8월 29일

댓글:

2019년 8월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by