clear allclose allclcx=rand(5,5)y=x(:,ones(1,3))%這是結果;你看看就懂了吧。x = 0.0971 0.0344 0.1869 0.7547 0.1190 0.8235 0.4387 0.4898 0.2760 0.4984 0.6948 0.3816 0.4456 0.6797 0.9597 0.3171 0.7655 0.6463 0.6551 0.3404 0.9502 0.7952 0.7094 0.1626 0.5853y = 0.0971 0.0971 0.0971 0.8235 0.8235 0.8235 0.6948 0.6948 0.6948 0.3171 0.3171 0.3171 0.9502 0.9502 0.9502 實際上就是取出x矩陣中的第1,1,1(ones(1,3)=[1 1 1])列;
clear allclose allclcx=rand(5,5)y=x(:,ones(1,3))%這是結果;你看看就懂了吧。x = 0.0971 0.0344 0.1869 0.7547 0.1190 0.8235 0.4387 0.4898 0.2760 0.4984 0.6948 0.3816 0.4456 0.6797 0.9597 0.3171 0.7655 0.6463 0.6551 0.3404 0.9502 0.7952 0.7094 0.1626 0.5853y = 0.0971 0.0971 0.0971 0.8235 0.8235 0.8235 0.6948 0.6948 0.6948 0.3171 0.3171 0.3171 0.9502 0.9502 0.9502 實際上就是取出x矩陣中的第1,1,1(ones(1,3)=[1 1 1])列;