How to combine multiple random matrix.

조회 수: 1 (최근 30일)
Asad Abbas
Asad Abbas 2016년 11월 14일
댓글: Daniel kiracofe 2016년 11월 15일
Need hepl please.
Here is given code where I am generating binary matix based on switch case. I want to "repmat" to generate final matrix.
for example:
In case 1 c1 matrix is generated and in case 2 c2 matrix generated and so on.
If c1, c2 and c4 matrix are generated. how i can "repmat" them using general command.
same as if c2 and c3 generated then without changing in code it should "repmat" c2 and c3.
If my question is not clear please let me know. I will explain more detail. Thanks
clear all
clc
global x1 x2 x3 x4 G group
G=input('Total number of Groups: ');
for j=1:G
group=input('group relationship case: ');
switch group;
case 1
%%Alternative
x1=input('Alternative features number: ');
y1=0:2^x1-1;
z1 = dec2bin(y1);
for i = 1:size(z1,2)
c1(:,i) = str2num(z1(:,i));
end
sum1 = sum(c1(:,:),2);
id1 = find(sum1 == 1);
c1=c1(id1,:);
case 2
%%Alternative optional
x2=input('Alternative Optional features number: ');
y2=0:2^x2-1;
z2 = dec2bin(y2);
for i = 1:size(z2,2)
c2(:,i) = str2num(z2(:,i));
end
sum2=sum(c2(:,:),2);
id2 = find (sum2<=1);
c2=c2(id2,:);
case 3
%%Optional
x3=input('Optional features number: ');
y3=0:2^x3-1;
z3 = dec2bin(y3);
for i = 1:size(z3,2)
c3(:,i) = str2num(z3(:,i));
end
sum3= sum(c3(:,:),2);
id3 = find (sum3<x3 | sum3==x3);
c3=c3(id3,:);
case 4
%%OR Group Mandatory
x4=input('OR group Mandatory features number: ');
y4=0:2^x4-1;
z4 = dec2bin(y4);
for i = 1:size(z4,2)
c4(:,i) = str2num(z4(:,i));
end
sum4=sum(c4(:,:),2);
id4 = find (sum4>0);
c4=c4(id4,:);
end
end
  댓글 수: 1
Daniel kiracofe
Daniel kiracofe 2016년 11월 15일
I think you should add more detail. I don't understand the question. What do you want the size of the final matrix to be relative to the size of the c1, c2, c3, and c4 matrices?

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

답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by