c value can't calculate

I want to get c and R value R value can achieve but the c value can't achieve
solvec only get (1,1) and (103,1) plz help me
for i=1:1:103
eqns = [R - z(i,1) * cos(theta(i,1) * pi/180) == 0, c + 1/(2 * pi * f(i,1) * abs(z(i,1)) * sin(theta(i,1) * pi/180)) == 0];
vars = [ c R ];
[ solc, solR ] = solve(eqns,vars);solvec = solvec(1,1);
solveR(i,1) = solR(1,1);
solvec(i,1) = solc(1,1);
end

3 Comments

Unfortunately I cannot test this as we do not have your f or theta or z values.
syms c R
Pi = sym(pi);
vars = [c, R];
for i=1:1:103
eqns = [R - z(i,1) * cosd(theta(i,1)) == 0, c + 1/(2 * Pi * f(i,1) * abs(z(i,1)) * sind(theta(i,1))) == 0];
[ solc, solR ] = solve(eqns,vars);
if isempty(solc)
solveR(i,1) = sym(nan);
solvec(i,1) = sym(nan);
else
solveR(i,1) = solR(1,1);
solvec(i,1) = solc(1,1);
end
end
I just copy the cord what you written then my problem solved. Thank you. But I have one question why my cord didn't work?
The main change was to make the calculation more accurate by switching to symbolic π instead of numeric, and switching to sind and cosd which can be more accurate for multiples of 90 degrees and some other special values.
You are using solve() which tries for infinitely precise solutions. If you end up with numeric round off then that can ruin the ability to find a solution in some cases

Sign in to comment.

Answers (0)

Tags

Asked:

on 13 Sep 2022

Commented:

on 14 Sep 2022

Community Treasure Hunt

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

Start Hunting!