mardi 15 novembre 2016

Matlab plot for many branches

I want to plot the following function

I(x) = 5*(1+x/2) for -2 < x < 0

   5*(1-x/2) for  0 < x < 2

       0     elsewhere

I use the following script:

clc; close all; clear all;

L = 4;

x = -20:1:20;

I((-L/2) < x & x<0) = 5*(1 + x/(L/2));

I(0 < x & x < (L/2)) = 5*(1 - x/(L/2));

plot (x,I), grid

It does not work. Could you please help me?

Aucun commentaire:

Enregistrer un commentaire