0
votes

I'm relatively new as a Scilab user and I have a question. Concerning the function bellow, I know how to plot "y" but I don't know how to plot the variable "z", inside the function. Is it possible to do that? Thanks.

function y=f(x)
    z = x+2
    y=z^3+6*z^2+11*z+6
endfunction
x = -10:0.1:10
plot(x, f)
1

1 Answers

0
votes

If you want to keep the calling style of plot you choosed (second argument is a function), then you will have to define a secondary function, like this:

function z = g(x)
    z = x+2
endfunction
function y = f(x)
    z = g(x)
    y = z^3+6*z^2+11*z+6
endfunction
x = -10:0.1:10
plot(x, f)
plot(x, g)