-1

i want to test this program with scilab, but when i run it, i get this error :

ATTENTION: Transposition of the line X vector to obtain compatible dimensions plot2d: Wrong dimension of input arguments: Incompatible dimensions.

here is the program :

t=0:400;
if t>=0 & t<=20 then
   v=0
else 
   v=15
end
plot(t,v)

1 Answers1

1

I think you are attempting to create a vector v whose values depend on the values of t. This means that where t is between 0 and 20, then v must be equal to 0, otherwise it must be equal to 15.

This code should produce what you are looking for:

t = 0:400;

v = zeros(size(t));
v(t > 20) = 15;

plot(t,v);

Actually, you have to create a zero-filled vector v of the same size of t and then, using a logical indexing, you have to set the values of v to 15 in correspondance of t being greater than 20.

Tommaso Belluzzo
  • 23,232
  • 8
  • 74
  • 98
  • thanks for your help, but can you help me to make the program of this graph please, [link](http://www.amperiste.fr/sitezz/default/files/cycle_extraurbain.JPG) – Mohamed El Hadi Mar 01 '18 at 23:09
  • It's not a program, it's a plot. Either find the equation or retrieve its data. – Tommaso Belluzzo Mar 01 '18 at 23:11
  • that's the problem, with the equation it's impossible to know, but there is a possibility with the data. I have the data but I need to make a loop for or if, because i don't want to repeat each time v (t <) or v (t>) :( – Mohamed El Hadi Mar 01 '18 at 23:19