MATLAB软件定义数组请教
求救大神:刚学习matlab软件老是让我们做下面这道题,
建立Function File, 用冒泡法对任意一维数组进行排序。函数名为sort1(注:与系统sort函数有所区别)
function a=sort1(a)
%UNTITLED3 Summary of this function goes here
% Detailed explanation goes here
for i=1:1:length(a)
for j=1:1:length(a)-i
if a(j)>a(j+1)
b=a(j);
a(j)=a(j+1);
a(j+1)=a(j);
end
end
end
disp(a);
end
这是我写的代码,但是为什么老是提示这个出错sort1,是不是我定义的格式不对?谢谢