How do I get the x vector from a fifth degree function with a given y vector ?
Información
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Mostrar comentarios más antiguos
Hello !
I have a fifth degree function as shown below:
F = @(x) -0.1304*x.^5 +0.2909*x.^4 - 0.2454*x.^3 + 0.042*x.^2 + 0.0693*x + 1.3332
and i have a vector for the given y values:
y = [1.3579 1.3571 1.3571 1.3567 1.3568 1.3565 1.357 1.3571 1.3571 1.353 1.3405 1.3361 1.3341]'
I want to know how to get the x solution for this problem.
Thanks in advance.
Respuestas (2)
KSSV
el 28 de Feb. de 2019
P = [-0.1304 0.2909 -0.2454 0.042 0.0693 1.3332] ;
y = [1.3579 1.3571 1.3571 1.3567 1.3568 1.3565 1.357 1.3571 1.3571 1.353 1.3405 1.3361 1.3341] ;
iwant = zeros(length(y),5) ;
for i = 1:length(y)
P1 = [P(1:end-1) P(end)-y(i)] ;
iwant(i,:) = roots(P1) ;
end
Stephan
el 28 de Feb. de 2019
Hi,
if you are interested in only the real solutions you can use:
y = [1.3579 1.3571 1.3571 1.3567 1.3568 1.3565 1.357 1.3571 1.3571 1.353 1.3405 1.3361 1.3341]';
F = @(x) -0.1304.*x.^5 +0.2909.*x.^4 - 0.2454.*x.^3 + 0.042.*x.^2 + 0.0693.*x + 1.3332 - y';
result = fsolve(F,ones(1,size(y,1)))
Result is:
result =
Columns 1 through 7
1.0221 1.0314 1.0314 1.0359 1.0348 1.0380 1.0325
Columns 8 through 13
1.0314 1.0314 1.0720 1.1567 1.1792 1.1885
Best regards
Stephan
La pregunta está cerrada.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!