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 Exchange에서 Data 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