Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Any one can help me to check this code ?

Asked by Brwa on 25 May 2013
A = [ 1 1 5; 2 1 6; 3 7 5 ];
B = ones(3,3)
S = eye(3,3)
O = [2 7 6; 3 7 0] 
   for j = 1: 1: 3
      R = A(1:end,j)     % get 3 column vectors. therefore i will have 3 (R)'s
      C = B * R ;        % 3x1 vector
      D = [B*S ; O,B*C]
      H = [zeros(3,3); S]
  end

I have doubt about the value of C, does it change with j in the loop?

by the way C is a matrix, i can not write C(j) because i want to use the whole matrix (3x3) not just some specific values inside C.

If i need to change something, please let me know.

Thanks

0 Comments

Brwa

Products

1 Answer

Answer by Azzi Abdelmalek on 25 May 2013
Edited by Azzi Abdelmalek on 25 May 2013
Accepted answer

There is a small mistake, it should be O' instead of O,

A = [ 1 1 5; 2 1 6; 3 7 5 ];
B = ones(3,3)
S = eye(3,3)
O = [2 7 6; 3 7 0]
for j = 1: 3
  R = A(1:end,j)     % get 3 column vectors. therefore i will have 3 (R)'s
  C = B * R ;        % 3x1 vector
  D = [B*S ; O' B*C]
  H = [zeros(3,3); S]
end

3 Comments

Brwa on 25 May 2013

yes, you are right about that, but my question is does loop can change the variavle C inside D for each value of j ? Or i need to write some thing like this C(j) or C(:,:,j) or any thing else ?

Azzi Abdelmalek on 25 May 2013

Yes C is changing every iteration, if you need to store each value of C , you can add in the loop

C1{j}=C
Brwa on 26 May 2013

Thank you

Azzi Abdelmalek

Contact us