index exceeds matrix dimension
Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Ältere Kommentare anzeigen
Recently i stumbled across a optimization problem using fminsearch but when i try to execute the code it says-"index exceeds matrix dimension" can someone help me how to solve this error?
f=@(x)( x(4)*(((x(1)^2*10^5*(2+2*0.5) + 2*x(1)*10^5*(1+0.5)*cos(((1+0.5)*pi)/2)+1)))^1/2*(((x(2)^2*10^5*(2+2*0.5)+ x(3)^2*10^10*0.5+ 2*x(2)*10^5*(1+0.5)*cos(((1+0.5)*pi)/2)+ 2*x(3)*10^5*(0.5)*cos((0.5.*pi)/2)+1))^-1/2)-0.0031622*(-10^5*2+108.0248)*((-10^5*2+0.607502)^2+(0.4562*x(5)^2))^-(1/2))^2;
options=optimset('Maxfunevals',10^10,'Maxiter',10^10,'display','final','tolfun',1e-20,'tolx',1e-20);
x=fminsearch(f,[0,-1,-2,-1],options);
Antworten (2)
Walter Roberson
am 11 Mai 2019
0 Stimmen
The code refers to x(5) fairly close to the end, so it needs a vector of 5 or more inputs. The number of inputs constructed by fminsearch is controlled by the length of initial value. You are passing an initial value of length 4 so only 4 values will be passed to your function.
madhan ravi
am 11 Mai 2019
Bearbeitet: madhan ravi
am 11 Mai 2019
Last x(5) should be x(4)
Also
.^
.*
./ % to be taken care of
Diese Frage ist geschlossen.
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!