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 Kommentare

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
지석
지석 am 14 Sep. 2022
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?
Walter Roberson
Walter Roberson am 14 Sep. 2022
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

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Tags

Gefragt:

am 13 Sep. 2022

Kommentiert:

am 14 Sep. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by