# Updating values in a 2x2 matrix , taking values from result of an iterative operation.

조회 수: 2(최근 30일)
Umair Ahmed 2021년 6월 19일
답변: SALAH ALRABEEI 2021년 6월 19일
So I want to create a 2x2 matrix. Then I want its element [1,1] to stor values from result of an operation (function) and the element [1,2] to store results of another operations. In short, the values will keep changing as the variable 't' changes . (since i will be using 't' in the operation.). My formula is below :
t = (1:30) #values of 't' from 1 to 30
p1 = 1-(5/6).^t #need to store this result at position [1,1] of matrix
p2= 1-p1 #Need to store this value at position [1,2] of matrix
The values for other two positions of matrix [2,1] and [2,2] should remain constant (0 and 1 respectively).
I don't know how to implement this.

댓글을 달려면 로그인하십시오.

### 답변(1개)

SALAH ALRABEEI 2021년 6월 19일
t=1:30;
p1= 1-(5/6).^t;
p2=1-p1;
p3=zeros(1,30); p4=ones(1,30);
A=cat(1,p1,p3,p2,p4)
A_all= reshape(A,2,2,30)

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!