Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

How to plot continous function with different definations

1 visualizzazione (ultimi 30 giorni)
Nikhil
Nikhil il 4 Ott 2013
Chiuso: MATLAB Answer Bot il 20 Ago 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

Risposte (0)

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by