give me Nan for r.

1 次查看(过去 30 天)
Khadija Sulail
Khadija Sulail 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