Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

divide matrix in equal parts in matlab

Status
Not open for further replies.

randy orton

Member level 1
Joined
Jan 19, 2011
Messages
41
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,592
Hello all
this is my matlab code as an output I am getting 1 matrix of 54*3 but instead of that i need 18 matrices of 3*3

like 1st 9 element will make 1 matrix than 10-18 will make another one and so on.

clc;
count=0;
Ci=zeros(0,0);
X=[0, 1/3, 2/3, 1, 1, 1, 1, 2/3, 1/3, 0, 0, 0, 1/3, 2/3, 1/3, 2/3];
Y=[1, 1, 1, 1, 2/3, 1/3, 0, 0, 0, 0, 1/3, 2/3, 2/3, 2/3, 1/3, 1/3];
Z=[12 13 1;
13 2 1;
13 14 2;
14 3 2;
14 5 3;
5 4 3;
11 15 12;
15 13 12;
15 16 13;
16 14 13;
16 6 14;
6 5 14;
10 9 11;
9 15 11;
9 8 15;
8 16 15;
8 7 16;
7 6 16];

for r=1:18;
I=Z(r,1);
J=Z(r,2);
K=Z(r,3);

sum=0;
P(1)=Y(J)-Y(K);
P(2)=Y(K)-Y(I);
P(3)=Y(I)-Y(J);
Q(1)=X(K)-X(J);
Q(2)=X(I)-X(K);
Q(3)=X(J)-X(I);

a=(P(2)*Q(3))-(P(3)*Q(2));
A=0.5*a;
d=4*A;
for i=1:3;
for j=1:3;
b=P(i)*P(j);
c=Q(i)*Q(j);
sum=b+c;
C=sum/d;
%matrix formation

v=count/3;
if(v==3)
x=floor(v);
else
x=floor(v)+1;
end
w=mod(count,3)+1;
Ci(x,w)=C;
count=count+1;

end
end
Ci

end

thQs in advance
cheers
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top