how to set more than 1 value to this code?

1 Ansicht (letzte 30 Tage)
yue ishida
yue ishida am 1 Sep. 2012
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?

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 1 Sep. 2012
Bearbeitet: Azzi Abdelmalek am 1 Sep. 2012
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

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by