function – error: __plt2vv__: vector lengths must match when using Newton’s method

I want to create a code that uses different values of a, within a certain interval, and applies Newton’s method, represented in the function t. Then, it takes the last iteration of t and uses it in y1_novo and y2_novo, I want this to repeat to all values of a. Then it takes the final y1 and y2 and graphs it in fuction of a. But I get this error `error: __plt2vv__: vector lengths must match error: called from __plt__>__plt2vv__ at line 487 column 5 __plt__>__plt2__ at line 247 column 14 __plt__ at line 132 column 16 plot at line 229 column 10 ex6_novo at line 31 column 3`

This is the code in question:

``````a = 1+sin(1):0.01:4+sin(2);
t0 = 1;
N = 306;
epsilon = 1e-5;
y1 = [];
y2 = [];
k = 1;
while k != length(a)
a_novo = a(k);
function [t, t_imp] = metodoDeNewton(a_novo, t0, N, epsilon)
t = zeros(1, N+1);
t(1) = t0;
for i = 1:N
t(i+1) = t(i) - (t(i).^2 - (a_novo - sin(t(i)))) ./ (2 .* t(i) - cos(t(i)));
if abs(t(i+1) - t(i)) < epsilon
t_imp = t(i+1);
break;
endif
endfor
endfunction

[t, t_imp] = metodoDeNewton(a_novo, t0, N, epsilon);
x = linspace(0, 1, N+1);
y1_novo = t_imp;
y2_novo = a_novo - sin(t_imp);
y1 = [y1, y1_novo];
y2 = [y2, y2_novo];
k = k + 1;
endwhile
``````

Any help would be appreciated!!