What function do I use instead of "matlabFunction"?

1 回表示 (過去 30 日間)
chayanon summueang
chayanon summueang 2019 年 2 月 12 日
編集済み: chayanon summueang 2019 年 2 月 12 日
It runs for a very long time and I need this function to use for define a function in my equation.
I want to define a function without use "matlabFunction". What function do i use to define a function?
Thank for help.
Example code
% Riemann summation loop
n2 = 1
dx1 = (TopR1-DownR1)/n2;
dy1 = (TopR2-DownR2)/n2;
dz1 = (TopR3-DownR3)/n2;
sumx = 0;
sumy = 0;
myequation = 0;
for i1 = 1:n2
sumx=sumx+subs(U2,x1,dx1*rand+(DownR1+(i1-1)*dx1)); % U2 is a function have 4 variables
end
sumx = sumx*dx1;
for j1 = 1:n2
sumy=sumy+subs(sumx,y1,dy1*rand+(DownR2+(j1-1)*dy1));
end
sumy = sumy*dy1;
for k1 = 1:n2
myequation=myequation+subs(sumy,z1,dz1*rand+(DownR3+(k1-1)*dz1));
end
myequation =myequation*dz1;
% plot graph
F1 = matlabFunction(myequation);
% range of varaible d
d = 0:0.01*(10^-9):20*(10^-9);
Potential = zeros(length(d));
for i1 = 1:length(d)
Potential(i1) = F1(d(i1));
end
figure('Name','Potential','NumberTitle','off');
plot(d,Potential)
  3 件のコメント
madhan ravi
madhan ravi 2019 年 2 月 12 日
Also I don't see why your using a loop.
chayanon summueang
chayanon summueang 2019 年 2 月 12 日
編集済み: chayanon summueang 2019 年 2 月 12 日
I upload "myequation". It is a loop after Riemann summation and U2 is a function that have 4 variables.
*4 variables. Sorry

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by