Hello, I am trying to run his code(attached) in matlab but solver does not run to give an answer or error. need help if anyone would know what is wrong with this code. I am trying to find xc1,yc1 with given input values(x1,y1,x2,y2,R)Any help would be very much appreciated.
Thanks

 Respuesta aceptada

Star Strider
Star Strider el 12 de Nov. de 2015

0 votos

The solver doesn’t run because you had it (and the line before it) as comments!
When I ran this I got [1.7, 0.07] for the results:
x1=1.35;
x2=2;
y1=0.07;
y2=0.07;
R=1.5;
initialvals = rand(1,2);
XCYC = fminsearch( @(xyc) (x1-xyc(1))^2+(y1-xyc(2))^2 - R^2 + (x2-xyc(1))^2+(y2-xyc(2))^2 - R^2, initialvals);

6 comentarios

avinash desh
avinash desh el 12 de Nov. de 2015
Hello, Would it be possible to attach your code, I am still unable to run to get the answers after removing the comments
Star Strider
Star Strider el 12 de Nov. de 2015
I did attach the relevant part of it, which was the solver fminsearch call.
Also, the semicolons (;) at the end of each line suppress Command Window output. Add this line at the end of your code:
Result = [xc1, yc1]
and you will see:
Result =
1.6750 1.5344
for [xc1 yc1].
avinash desh
avinash desh el 12 de Nov. de 2015
Thank you, it works. I did not realize I had semicolon's.
Star Strider
Star Strider el 12 de Nov. de 2015
My pleasure.
avinash desh
avinash desh el 12 de Nov. de 2015
Hello Sir, I have run into another issue with a different code.I have attached my code for which I ma getting "Subscript indices must either be real positive integers or logicals" error. I am trying to plot u,v from data file, which has 10000 pieces of data (basically in x,y,z). xi,yi are the centers and trying to plot contours on pad between concentric circles(between ri and r0). Any help with this error I would very much appreciate it.
Thanks
Walter Roberson
Walter Roberson el 13 de Nov. de 2015
This has been answered in the Question you created for this topic.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Etiquetas

Preguntada:

el 12 de Nov. de 2015

Comentada:

el 13 de Nov. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by