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

Iterations in matlab.

Asked by Pranjal Pathak on 30 Jan 2012

Hi,

I have done a coding in matlab and this is the point where I am hanging,can anyone please help me out?

I have an equation

P(i,j)=Q(i,j)+R(i,j)/2;

Where P,Q,R are all matrices of dim=4x4.

Values of R(i,j) is given to us.

Now,initially assuming Q-matrix to be a zero matrix (all the elements are 0), the P(i,j) matrix is calculated. My, problem is that, once I calculate the P-matrix, I want to assign its value to the Q-matrix (a new Q-matrix instead of the initial zero matrix) to calculate a new P(i,j)-matrix. In this way I want to run the iterations for 4-times.

Will anyone please help me out over here?

Thanking You!

2 Comments

Jan Simon on 30 Jan 2012

Please post the existing code and explain, which problems occur. To help you out, it is required to know the problem.

Walter Roberson on 30 Jan 2012

Last known code was completely non-functional: <http://www.mathworks.com/matlabcentral/answers/27367-matrix-iterative-solution-using-matlab>

Pranjal Pathak

Products

No products are associated with this question.

1 Answer

Answer by Jan Simon on 30 Jan 2012
Accepted answer

Do you mean something like this:

Q = zeros(4, 4);
R = magic(4);
for k = 1:4
  P = Q + R;
  Q = P;
end

?

1 Comment

Pranjal Pathak on 31 Jan 2012

Thanks Simon Sir!
Yeah! your hint help me out.

Jan Simon

Contact us