フィルターのクリア

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 Center および File ExchangeCalculus についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by