What function do I use instead of "matlabFunction"?

조회 수: 10 (최근 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 CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by