Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Hi experts, please give me a solution, i want to comparison of the approximate error to find the root of the function (x+2)^3+1 with two methods such as secant method and bisection method in matlab code. I am new in matlab coding. Need help

1 visualización (últimos 30 días)
My two code is like if i get error data(y1,y2) of two method & iteration data(x), but i can't work. It shows same error in two code like vectors must be same lengths in 5th line(1st code)& in 3th line(second code) .
x= 0:2:14
y1=[6 2 5 6 7 8 9 ];
y2=[2 3 4 5 7 8 9 ];
figure;
plot(x,y1)
hold on
plot(x,y2)
hold off
Second code is
x = linspace(0,20)
y =[6 2 5 6 7 8 9 ];
plot(x,y)
xlabel('x-axis')
ylabel('y-axis')
y= [2 3 4 5 7 8 9 ]
z= [6 2 5 6 7 8 9 ]
plot(x,z,x,y)
grid on
axis auto
legend('squared','cubic')
  3 comentarios
Geoff Hayes
Geoff Hayes el 2 de Jul. de 2019
The solution is to ensure that the arrays have the same number of elements.
x= 0:2:14
y1=[6 2 5 6 7 8 9 12];
and
x = linspace(0,20,7)
y =[6 2 5 6 7 8 9 ];

Respuestas (0)

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by