Can any body help me to form a full matrix which is having sub matrices.And these sub matrices are similar to each other. I have used counter to repeat the same calculation. where i is varying row wise and similarly k is varying column wise.
Show older comments
row1=1;row2=2;lo1=1;lo2=2;
for i=1:3 (when i=1 it will evaluate the first block matrix, similarly when i=2...)
row1=row1+2;row2=row2+2;lo1=lo1+2;lo2=lo2+2;
for k=4:9
D5(row1,lo1)= - V(i)*V(k)*abs(Y(i,k))*sin(Th(i)-Th(k)-angle(Y(i,k)));
D5(row1,lo2)= - V(i)*abs(Y(i,k))*cos(Th(i)-Th(k)-angle(Y(i,k)));
D5(row2,lo1)= V(i)*V(k)*abs(Y(i,k))*cos(Th(i)-Th(k)-angle(Y(i,k)));
D5(row2,lo2)= - V(i)*abs(Y(i,k))*sin(Th(i)-Th(k)-angle(Y(i,k)));
end
end
3 Comments
James Tursa
on 9 Mar 2015
What do you need help with? Does this code give you the result you want or not? Are you looking for improvements or corrections?
prasenjit dey
on 9 Mar 2015
prasenjit dey
on 9 Mar 2015
Accepted Answer
More Answers (1)
prasenjit dey
on 9 Mar 2015
0 votes
1 Comment
Roger Stafford
on 9 Mar 2015
As I see it, Prasenjit, you have two problems, the first being to determine the locations in vectors V and Th and matrix Y to be used in the computations of D5 values, and the second being just where to store those results. If these proceed in a regular fashion with blocks packed adjacent to one another in a rectangular pattern, as I speculated in my answer, you can use the i and k quantities in the for-loops to determine both of these. On the other hand if one or the other of these locations is irregular in some respect, requiring some kind of "type" vector, then you can compute the needed indices directly from type(i) or type(k). If at all possible, you should avoid the method you wrote:
If type(i)==3 && type (k)==2
as this may lead to very cumbersome, ugly coding.
If my response seems vague, it is because I do not fully understand what it is you are trying to do. It might help if you could give a simple example of the desired arrangement of D5 value blocks in what you called "submatrices".
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!