What function do I use instead of "matlabFunction"?
Show older comments
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 Comments
madhan ravi
on 12 Feb 2019
upload "myequation"
madhan ravi
on 12 Feb 2019
Also I don't see why your using a loop.
chayanon summueang
on 12 Feb 2019
Edited: chayanon summueang
on 12 Feb 2019
Answers (0)
Categories
Find more on Startup and Shutdown 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!