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 日

0 投票

Determine which variables are inputs and outputs. Then assign them in this manner:
function [out1, out2, out3] = yourFunctionName(in1, in2, in3)

カテゴリ

ヘルプ センター および File ExchangeData Types についてさらに検索

質問済み:

2020 年 4 月 21 日

編集済み:

2020 年 4 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by