matlab - Plotting own function in scilab -



matlab - Plotting own function in scilab -

hey have issuse plotting own function in scilab. want plot next function

function f = test(n) if n < 0 f(n) = 0; elseif n <= 1 & n >= 0 f(n) = sin((%pi * n)/2); else f(n) = 1; end endfunction

followed the console command

x = [-2:0.1:2]; plot(x, test(x));

i loaded function , next error

!--error 21 invalid index. @ line 7 of function lala called : plot(x, test(x))

can please tell me how can prepare this

so did loop. don't think best solution can't other ones running atm...

function f = test(n) f = zeros(size(n)); t = length(n); = 1:t if n(i) < 0 f(i) = 0; elseif n(i) <= 1 & n(i) >= 0 f(i) = sin((%pi * n(i)/2)); elseif n(i) > 1 f(i) = 1; end end endfunction

i guess need find source issue , used features , perks matlab/scilab have on :) help tho

matlab function plot scilab

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -