how to set more than 1 value to this code?

1 次查看(过去 30 天)
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 File Operations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by