I'm writing a code to find the intersection points of two circles.

The circirc function is giving me assert problems, so is the assert function.
I will not link the whole question, since that would be defeating the purpose of actually working on the code and learning.
The question will get more complicated deep through, but the starting point is finding the points of intesection of two circles of variable centers and radii.
PS. I'm a uni student and MATLAB is not fun at all for me. The code might look terribly hideous and I apologize for that. Can someone give tips to start enjoying MATLAB more and have a faster and more effective way of learning all its functionalities. Thanks in advance.
PPS. This code is due to next week and I would really appreciate a quick reply! Thanks again <3
Here is the code:
%DEFINE INPUT PARAMETERS%
syms x y
A = [x y];
B = [x y];
C = [x y];
D = [x y];
AB = norm(A-B);
CD = norm(C-D);
AC = norm(A-C);
%ASSUMPTIONS%
assume(x, 'real');
assume(y, 'real');
assume(AB > 0 );
assume(CD > 0 );
assume(AC > 0 );
%FINDING INTERSECTION%
assert(AB > 0 && CD > 0); %what is happening here?%
[xint, yint] = circcirc(A(1),A(2),AB,C(1),C(2),CD);
%Error using assert
Assertion failed.
Error in problem_geogebra1 (line 61)
assert(AB > 0 && CD > 0);%
E = [xint(1), yint(1)];
F = [xint(2), yint(2)];

5 Comments

circcirc is a function that works normally if the given arguments are real and positive. My variables were predefined and didn't need to be defined once again. As I mentioned before, this is a Uni question and I couldn't link the whole thing to this forum for obvious reasons.
A big note for all the other students who might seek help in the future: Chat gpt will provide instant help with your matlab code, unlike this forum. I almost skipped my deadline waiting for the mvps to show up and answer my very simple question, but Chat gpt literally saved the whole project.
Glad you found an answer to your question. In defense of those "mvps" (of whom I am not one), most of them work without being paid by MATLAB, answering questions here out of a genuine desire to help out, rather than any obligation. It's good to remember that they're volunteers, just trying to help out. It's good to hear more about another resource in ChatGPT though, especially if there's no one available to help immediately.
As for the question, I've found most responders happy to help answer questions especially for university students. I'm still not sure what your actual question was though!
I was not, in any way, playing the offence card on the MVPs. I repsect their work and really appreciate that they put in some of their personal free time to help others. My message about ChatGPT was directed to uni students, like me, who seek imediate help. Please care that this website is not always accurate, and can mess up a lot of the times. But for easy questions, like mine for example, it wouldn't be optimal to wait for someone to answer your question.
This forum is still a great place for anyone who wants to intensively learn better MATLAB and advance, especially when the questions are handled by great and experienced members.
With all due respect, some moderators may be out of line some times, but I guess maybe misunderstanding takes place, and that is where things go south...
Thank you, Mr Morris, you were incredibly helpful throughout the whole process of finding the answer, and I wish you a pleasant holiday and a happy new year.
Can you show a diagram? It might help. And why can't you just set the two equations equal to each other?
(x-xc1)^2 + (y-yc1)^2 = r1^2
(x-xc2)^2 + (y-yc2)^2 = r2^2
Two equations, two unknowns
Sorry, Image Analyst, the question has been solved and the code has been submitted already. I aced the homework!
Please reffer to the older comments on this thread. The inputs where defined for circcirc, and I accidentally redefined them.
Please take a deep look at this thread, some moderation issues have to be resolved.
Thanks in advance!

Sign in to comment.

Answers (2)

You can find the documentation for assert here: https://www.mathworks.com/help/sltest/ref/assert.html
Assert stops your simulation if the expression passed to it is false. In this case, the expression is making sure that the line AB and the line CD are both positive. I am curious how it failed, to my knowledge norm should always return a positive number, though perhaps we're just missing some pieces of the problem (as you stated) where AB and CD were adjusted.
As for enjoying MATLAB, the thrill is in the journey. Just like with learning a new language, the first couple of steps are the most frustrating while you learn the basics. Don't give up just because it's hard at the start!

3 Comments

Thanks for the quick reply!
As for AB and CD: Both lines have not been altered after the first few lines.
Actually, this is just the beginnning of my code, and all the imputs are still fresh and new.
I will take a look at the link you provided, but I really hope it's not one that I have already read and marked as useless in my situation.
Thanks again, please do follow up on this thread if any of the information I provided will help solve my struggle.
I'm actually not sure what your question is, are you having trouble understanding assert? Or with an error being thrown by assert?
everytime i use circcirc, the error comes out of nowhere. I don't understand what is wrong with my circcirc!

Sign in to comment.

You had a problem in the use of syms here, causing an error.
syms x y
A = [x y];
B = [x y];
C = [x y];
D = [x y];
AB = norm(A-B);
CD = norm(C-D);
AC = norm(A-C);
%ASSUMPTIONS%
assume(x, 'real');
assume(y, 'real');
assume(AB > 0 );
Warning: Ignored assumptions on constants.
assume(CD > 0 );
Warning: Ignored assumptions on constants.
assume(AC > 0 );
Warning: Ignored assumptions on constants.
The warnings are just warnings, but they tell something useful, IF you look at them carefully and you think about the value of those variables.
What is AB here? CD?
AB
AB = 
0
CD
CD = 
0
Do you see they are identically zero? Now, let me perform two sets of asserts...
%FINDING INTERSECTION%
assert(AB >= 0 && CD >= 0); %what is happening here?%
No error is generated.
assert(AB > 0 && CD > 0); %what is happening here?%
Error using assert
Assertion failed.
So AB and CD are both identically zero. That means the assertion must fail, because you were asserting these parameters must be POSITIVE. Had you allowed zero in the assertion, it would not have caused an assertion failure.
As far as receiving an answer in a more timely way, we are not paid to answer questions immediately. We are here by choice, and are not paid at all. If someone sees your question when you want an answer, and they know the answer, then you will get an answer quickly. Sorry, but that is how a volunteer forum works. And if you post a question at an inopportune time when maybe nobody is awake or those who could answer are having dinner, then you get an answer when someone is able to answer and not before.

1 Comment

"If someone sees your question when you want an answer, and they know the answer, then you will get an answer quickly"
I will be holding on to this quote for personal reasons.
I'm not in a position to argue about Matlab, but I have the absolute authority to accept the answer to my own question, especially when it's right. Thank you for your very helpful contribution, but I would rather deam my answer as the right one in my case, since the given paremeters where to be replaced during the examination of the code. I by no means agree with the blind authority of unaccepting someone's answer when it surely is correct. Please reverse your actions and allow me to accept the correct answer, so that people facing the same problem have a better understanding of how circcirc works. If not, please go ahead and delete this thread/entire question.
Thank you for your time, John

Sign in to comment.

Products

Tags

Asked:

on 8 Dec 2022

Edited:

on 20 Dec 2022

Community Treasure Hunt

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

Start Hunting!