摘要: Matlab是矩阵运算的神器,所以可以很轻易的交换任意行或列,而且写法非常简洁,如下所示:a = [1 2 3; 4 5 6; 7 8 9];b = a;b(:,[1;2]) = b(:,[2;1]); % Swap col 1 and 2c = a;c([1;2],:) = c([2;1],:);... 阅读全文
posted @ 2015-08-09 11:32 Grandyang 阅读(3689) 评论(0) 推荐(0)
摘要: 4.9 You are given a binary tree in which each node contains a value. Design an algorithm to print all paths which sum to a given value. The path does 阅读全文
posted @ 2015-08-09 10:05 Grandyang 阅读(1121) 评论(3) 推荐(0)
摘要: 在MatLab中,我们有时要给画出的点按一定顺序标上序号,下面这个简单的例子实现这个功能:x=rand(1,10);y=rand(1,10);plot(x,y,'r*');text(x+0.02,y,num2cell(1:10)); 阅读全文
posted @ 2015-08-09 07:06 Grandyang 阅读(2785) 评论(0) 推荐(0)
Fork me on GitHub