How can I change variables in for loop in order to use the variables in subs?
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!