HOW TO WRITE THE FOLLOWING FUNCTION IN A MATLAB PROGRAM ? ALSO TELL THE WAY TO PLOT F(X)
조회 수: 2 (최근 30일)
이전 댓글 표시
F(X) =X , in (0,1) and F(X) =(X/2)+5 in (1,2)
댓글 수: 1
답변 (1개)
Sara
2014년 7월 16일
x = linspace(1e-6,2-1e-6,100);
f1 = x(x>0&x<1);
f2 = x(x>1&x<2)/2+5;
plot(x,[f1,f2])
댓글 수: 2
Sara
2014년 7월 16일
I'll crash since x and [f1,f2] will be of different sizes. That's a cheap and easy solution to plot the function, not meant to represent all the occurrences. Can be modified as:
plot(x(x>0&x<2&x~=1),[f1,f2])
참고 항목
카테고리
Help Center 및 File Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!