作业帮 > 综合 > 作业

matlab 函数参数传递

来源:学生作业帮 编辑:拍题作业网作业帮 分类:综合作业 时间:2024/04/19 09:30:58
matlab 函数参数传递
C++的函数参数传递有引用传递,指针传递,和实参传递,那么matlab的函数传递有几种.我写了一个函数
function y = my_sort(x);
for i=1:10
for j=1:9
if x(j) > x(j+1)
tmp = x(j);
x(j) = x(j+1);
x(j+1) = tmp;
end;
end;
end;
x
调用时为 my_sort(a),结果是a不变,x成了我想要的结果.
如何将结果变成a改变
use command x=mysort(x) try following codes.
function y = my_sort(x);
for i=1:10
for j=1:9
if x(j) > x(j+1)
tmp = x(j);
x(j) = x(j+1);
x(j+1) = tmp;
end;
end;
end;
y