I'm using a function in MATLAB for the first time. The function body is working properly., but when it is called from a program it giving an error.
The function is:
function f = adjust(value)
if value < 0
s = -1;
value = -value;
else
s = 1;
end
b = floor(value);
value = value-b;
value = s*value;
f = sprintf('%.14f', value);
Main program is
x(1) = 0.3;
y(1) = -0.4;
a = 36;
for n = 2:16
temp = a*(y(n-1)-x(n-1));
x(n) = adjust(temp);
end
I want to generate a number of values with precision 1e-14.
When I run the program, I get the error
??? In an assignment A(I) = B, the number of elements in B and
I must be the same.
Error in ==> one at 6
x(n) = adjust(temp);"
I don't know what to do with this. Please help me if you can.