How can I write MATRIX?

조회 수: 8 (최근 30일)
Nhl
Nhl 2014년 7월 8일
편집: Nhl 2014년 7월 8일
When the programme run I must abtain below
matrix(1,2)=1; matrix(2,1)=1; matrix(1,3)=1; matrix(3,1)=1; matrix(2,3)=1; matrix(3,2)=1;
What can I write instead of question tag in the below matlab programme to obtain matrix(1,2)=1; matrix(2,1)=1; matrix(1,3)=1; matrix(3,1)=1; matrix(2,3)=1; matrix(3,2)=1; ?
%%%%%%%%%%%%%%%%%%%%%%%%%%% clc matrix=zeros(10,10); for i=1:? matrix(?,?) = 1; matrix(?,?) = 1; end

채택된 답변

Anthony
Anthony 2014년 7월 8일
I am not sure to have understood your question but you should try:
M =1-eye(10);
By the way: avoid loops in Matlab ;-) Hope it helps,

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by