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

 採用された回答

Star Strider
Star Strider 2015 年 11 月 12 日

0 投票

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 件のコメント

avinash desh
avinash desh 2015 年 11 月 12 日
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 2015 年 11 月 12 日
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 2015 年 11 月 12 日
Thank you, it works. I did not realize I had semicolon's.
Star Strider
Star Strider 2015 年 11 月 12 日
My pleasure.
avinash desh
avinash desh 2015 年 11 月 12 日
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 2015 年 11 月 13 日
This has been answered in the Question you created for this topic.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by