how to set more than 1 value to this code?

조회 수: 1 (최근 30일)
yue ishida
yue ishida 2012년 9월 1일
Hi...this is my code. rs = m; n=7;
OFF = [m n];
A=zeros(m,n);
B = repmat(eye(n),ceil(m/n),1);
i1 = randi(n); % start in i1'th column
Bout = circshift(B,[0 i1-1]);
Bout = Bout(1:m,:);
this code is just functioning for 1 value..how can i add one more value without change the matric?

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2012년 9월 1일
편집: Azzi Abdelmalek 2012년 9월 1일
you have already posted this question,
x=1; n=13,m=7,n1=5 ; A=zeros(n,m);% n1 is your random number
A(sum([ 1:n; mod(n1-1:n+n1-2,m)*n]))=x
%if you want add another x and n1 without changing A
x=2;n1=4 % for example
A(sum([ 1:n; mod(n1-1:n+n1-2,m)*n]))=x
%you can repeat this as you want
  댓글 수: 1
yue ishida
yue ishida 2012년 9월 1일
thanx for the answer...its very helpful...

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by