The red markers in the right column indicates that something is seriously wrong
Right click function
(There is already a function named sort in Matlab. Pick another name. )
Remove the first line (and add end as the last line).
Try
function y = my_sort( v )
n = length( v );
sorted = 0;
k = 0;
while ~sorted
sorted = 1;
k = k + 1;
for j = 1:n-k
if v(j) > v(j + 1)
t = v(j);
v(j) = v(j + 1);
v(j + 1) = t;
sorted = 0;
end
end
end
y = x;
end
I get
Cannot find an exact (case-sensitive) match for 'x
The closest match is: X in H:\m\cssm\X.m
Error in my_sort (line 19)
y = x;
Replace
by
and try again
>> my_sort( randi(12,1,6) )
ans =
2 4 7 12 12 12
>>
Best Answer
Are you sure you have a problem with your code? I increased N to 16000, and plotted your data. It sure looks like a Hénon attractor to me.