converting a program to function

Hi guys,
I have written a probrem depend on x values and also ı want to convert to a function it can usefull in commond windows like:
>>G(1.15)
G{1.15}=1.200
ı want do that with function command
my program
x= input('pleasei');
x1=x;
count=1;
sums=1;
lastterm=1;
inc2=0;
fact=2;
newterm=1;
n=2;
rcx=1;
while rcx/1000<newterm
count=count+1;
if rcx/1000<newterm && count~=1
x1=x1*x;
end
while sums/1000<abs(lastterm)
%count=count+2;
ust= x^2;
inc2=inc2+2;
%inc3=inc3+1;
alt=(inc2)^2;
farkterm1=-(ust/alt);
lastterm=lastterm*farkterm1;
sums = sums+lastterm;
%ax1=abs(lastterm)/1000;
end
if count~=1
n=n+1;
fact=fact*n;
newterm=sums/fact;
rcx=rcx+newterm;
else
rcx=sums;
end
end
thank you

回答(1 个)

Adam Danz
Adam Danz 2020-4-21
编辑:Adam Danz 2020-4-22
Determine which variables are inputs and outputs. Then assign them in this manner:
function [out1, out2, out3] = yourFunctionName(in1, in2, in3)

类别

在 帮助中心 和 File Exchange 中查找有关 MATLAB Support Package for Arduino Hardware 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by