필터 지우기
필터 지우기

give me Nan for r.

조회 수: 1 (최근 30일)
Khadija Sulail
Khadija Sulail 2019년 9월 29일
답변: the cyclist 2019년 9월 29일
I have to answer this question which is dificult to do it by hand so I tried to search for another method and I found this code but it won't work with me, and can you explain why yhe use of syms r phir phi in the begning? and why did they use eval?
clc; clear all; close all;
syms r phir phi
tol = 1e-6; %setting tolerance%
dr = tol + 1;
g = 0.9;
Ms = 100; %value of Ms was given%
Ma = 0.1; %value of Ma was given%
Ms_ = Ms*(1-g);
Mt_ = Ma + Ms_;
D = (1/3)* (Mt_);
del = sqrt(D/Ma); % del stand for delta%
y = 0.1 - (exp(-r/del)/(4*pi*D*r)); % the function I have from calculation%
r = 1;%assumption that r=1%
while (abs(dr) > tol)
dr = eval(y/(diff(y))); % to calculate dr%
r = r - dr; % the new value of r%
end
fprintf('R = '); %printing the result%
r

답변 (1개)

the cyclist
the cyclist 2019년 9월 29일
The syms command is because that code is using the Symbolic Math Toolbox.

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by