I have a code like this:
t = a:(b-a)/10:b;
y = myFunction(t);
As far as I guess, this code creates an array t
, and another array y
by applying each value of t
to myFunction
.
However, if I manually pass the first element of array t
to myFunction
like this
y = myFunction(t);
I will not get the first element of y
but a different number. Why?
P.S.myFunction
looks like this:
function res = myFunction(x)
res = tanh(5*x.^2 + 3*x - 2) + exp((x.^3 + 6*x.^2 + 12*x + 8)/(2*x.^2 + 8*x + 7))-2.0;
end
In myFunction
you are performing a right matrix divide (using /
) whereas you intend to use element-wise divide (using ./
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With