give me Nan for r.
1 view (last 30 days)
Show older comments
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
0 Comments
Answers (1)
See Also
Categories
Find more on Numbers and Precision in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!