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
Walter Roberson
2022년 9월 13일
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
지석
2022년 9월 14일
Walter Roberson
2022년 9월 14일
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
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!