how solve index exceed matrix dimension??
Show older comments
%A CREATES A RANDOM MATRIX OF MAXIMUM INTERGER OF 10
rng('default');
A = randi(10, 20, 1);% A randi is a 20x20 matrix selected from discrete uniform integers whose range is from 1 to 10
B = [];%ELEMENTS ARE INSERTED IN B
for i = 1:20 %the elements ranges from 1 to 20 B = [B, A]; A = circshift(A, 2); end
disp(B)
I= eye(20) %COL 1
I(1,:)=1/9*I(1,:) I(2,:)=I(2,:)-10*I(1,:) I(3,:)=I(3,:)-2*I(1,:) I(4,:)=I(4,:)-10*I(1,:) I(5,:)=I(5,:)-7*I(1,:) I(6,:)=I(6,:)-I(1,:) I(7,:)=I(7,:)-3*I(1,:) I(8,:)=I(8,:)-6*I(1,:) I(9,:)=I(9,:)-10*I(1,:) I(10,:)=I(10,:)-10*I(1,:) I(11,:)=I(11,:)-2*I(1,:) I(12,:)=I(12,:)-10*I(1,:) I(13,:)=I(13,:)-10*I(1,:) I(14,:)=I(14,:)-5*I(1,:) I(15,:)=I(15,:)-9*I(1,:) I(16,:)=I(16,:)-2*I(1,:) I(17,:)=I(17,:)-5*I(1,:) I(18,:)=I(18,:)-10*I(1,:) I(19,:)=I(19,:)-8*I(1,:) I(20,:)=I(20,:)-10*I(1,:)
%COL 2
I(1,:)= I(1,:)- I(2,:) I(3,:)=1/7*I(3,:)-I(2,:) I(4,:)=I(4,:)-I(2,:) I(5,:)=-I(5,:)-4*I(2,:) I(6,:)=1/9*I(6,:)-I(2,:) I(7,:)=I(7,:)-4*I(2,:) I(8,:)=-I(8,:)-4*I(2,:) I(9,:)=-1/6*I(9,:)-I(2,:) I(10,:)=-I(10,:)-3*I(2,:) I(11,:)=-1/8*I(11,:)+I(2,:) I(12,:)=I(12,:)-I(2,:) I(13,:)=-1/7*I(13,:)-I(2,:) I(14,:)=-1/6*I(14,:)+I(2,:) I(15,:)=I(15,:)-2*I(2,:) I(16,:)=I(16,:)-3*I(2,:) I(17,:)=1/5*I(17,:)-I(2,:) I(18,:)=-1/7*I(18,:)-I(2,:) I(19,:)=-I(19,:)-2*I(2,:) I(20,:)=I(20,:)-I(2,:)
augB= [I B]
C= I*augB
D=round(C )
1 Comment
Jan
on 20 Jun 2017
Without formatting the code is not readable. Use the "{} Code" button to solve this. Please be patient with me, because this is explained several times each day for some years now.
In addition posting the complete error message would the readers allow to see the line, which causes the error. This is more efficient then guessing, where the problem occurs.
Accepted Answer
More Answers (0)
Categories
Find more on Operating on Diagonal Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!