Matlab Function returns values

조회 수: 1 (최근 30일)
lilly lord
lilly lord 2021년 2월 8일
댓글: lilly lord 2021년 2월 8일
Hi. I have written a function which should return two sequences but it returns only single sequence. I have attached the code below if any one help me in this regard. Thanks in advance
function [X, Y ]= Hybrid(a,b,w0,s0,c,u);
%a=1.4, b=0.3, wo= 0.1, s0=0.1, c=0.4, u=0.9
x(1)=0;
y(1)=0;
x0=0;y0=0;
% Initialize
t=0.4-6/(1+x0^2+y0^2);
x(1,1)=1+u*(x0*cos(t)-y0*sin(t));% mu is u
y(1,1)=u*(x0*sin(t)+y0*cos(t));
% Simulate
n=10000;
X1=[];
Y1=[];
for i=2:n
t=0.4-6/(1+x(i-1,1)^2+y(i-1,1)^2);
x(i,1)=1+u*(x(i-1,1)*cos(t)-y(i-1,1)*sin(t));
x_1(i,1)=mod(ceil(abs(x(i))*10000),256);
%x2_new = unique(x_1,'stable');
y(i,1)=u*(x(i-1,1)*sin(t)+y(i-1,1)*cos(t));
y_1(i,1)=mod(ceil(abs(y(i,1))*10000),256);
%y2_new=unique(y_1,'stable');
X1=x_1;
Y1=y_1;
end
plot(x,y,'.','MarkerSize',4)
X=unique(mod(x_1,256),'stable')'; % unique pooints of x chaotic sequence
Y=unique(mod(y_1,256),'stable')'; % unique point of y choatic sequence
end
It returns only X sequence

채택된 답변

the cyclist
the cyclist 2021년 2월 8일
How are you calling the function? If you call it like this
Hybrid(a,b,w0,s0,c,u)
then it will only return the first output. But it should return both if you call it like this
[X,Y]= Hybrid(a,b,w0,s0,c,u)
If that does not explain it, please post more information about how you are calling the function.
  댓글 수: 1
lilly lord
lilly lord 2021년 2월 8일
Oh my God. U r 100 % right. Thank u very much.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by