Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
How to plot continous function with different definations
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello all, I want to plot variation of function P(x) over range of x from -10 till 20 where P(x) is defined as P(x)= 0 if x<=0; =x if 0<=x<=1; =2-x if 1<=x<=2; =0 for x>2;
for this I have written following code: clear; dx=0.5; x=-10:dx:20; function z = bilinear(x) if x>=2 z=0; elseif 2>x>=1 z=2-x; elseif 1>x>=0 z=x; else z=0; end fp=bilinear(x); plot(x,fp);
and matlab is giving me following error: ??? Error: File: Q2.m Line: 3 Column: 1 Function definitions are not permitted in this context.
Can somebody please help me to debug this,
Thanks in advance,
Nikhil
댓글 수: 0
답변 (0개)
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!