How can I change variables in for loop in order to use the variables in subs?
Show older comments
I would like to find out intersection (coordinate) between circle and line.
One thing remarked is that
I want to change the slope of the line by change 'th' in for loop as shown below code, so that I will have matrix of intersection coordinates.
The problem is that when function 'subs' replace the 'th' in eq. as looping over, it does not evaluate 'xc' and 'yc'.
I want to have exact numeric result such as
xc = 365
yc = -235
but the result returns like
xc = -((350*tan(th)*(tan(th)^2 - 3)^(1/2) + 700)/(tan(th)^2 + 1) - 700)/tan(th) ((350*tan(th)*(tan(th)^2 - 3)^(1/2) - 700)/(tan(th)^2 + 1) + 700)/tan(th)
Anything I am missing?
Thanks in advance.
if true
% code
end
syms x y a thr;
eq1='x^2+y^2=a^2'
eq2='y=tan(th)*x-2*a'
[xc,yc]=solve(eq1,eq2,x,y)
k=1;
for th=0:90 %count the number of th
k=k+1;
end
k=k-1;
th=0:90; %th matrix
for s=1:k
th(s)=th(s)*pi/180;
subs(xc,{a,th},{350,th(s)})
subs(xc,{a,th},{350,th(s)})
end
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!