0

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.

1 Answer 1

2

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;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.