Can anyone tell me what the basic idea behind varying rows or columns in a matrix with respect to the row/column number is in matlab? I've been trying to replace all the columns in a given matrix by
i=1:101;
V=ones(121,101);
V_t=1000*10.^((i-1)/20);
e=V_arr(开发者_运维技巧1:121)';
V_arr=V; V_arr(:,i)=V_t*e;
I know that the error lies in trying to replace a number of columns with respect to all rows, and I've seen an alternative, simpler method using repmat, but I'd like to know if there's a method similar to the one above. Thanks.
One thing you can do is to use matrix multiplication, i.e. a n-by-1
array multiplied by an 1-by-m
array creates a n-by-m
array.
For example
ii = 1:101; %# 1-by-101
V_t = 1000*10.^((i-1)/20);
ee = ones(121,1); %# 121-by-1
V_arr = ee * V_t;
精彩评论