Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

How to plot continous function with different definations

1 Ansicht (letzte 30 Tage)
Nikhil
Nikhil am 4 Okt. 2013
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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

Antworten (0)

Diese Frage ist geschlossen.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by