Building of cell array of n*n

1 view (last 30 days)
surendra kumar Aralapura mariyappa
Commented: Qayray on 23 Jun 2019
Hey all,
I am not getting how to explain the problem in which I am stuck. But I wil try to do make it understandable to all with examples where it needs.
I am working on a project to build the user interface(Not GUI). Here User has to give some inputs in the form of matrix(either 1-D or 2-D).
For an example, Contact Area matrix between two materials.
Contact_Area = [ A_1_1 A_1_2 A_1_3; A_2_1 A_2_2 A_2_3; A_3_1 A_3_2 A_3_3] % A_1_1,A_2_2 and so on will be zero always.
% A_1_2 and A_2_1 and so on will be same always
Let's consider we have three square metals, Square metal 1 is inside 2 and 3 is placed in next to 2.
Here Some materials have a maximum of six contact area with other materials.
For an example, If we consider a square metal 1 and this square metal 1 is inside another square metal(2).
Here we can easily say that square metals 1 and 2 have six contact points. Contact areas are Vertical left, vertical right, Horizontal/vertical front, Horizontal/vertical back, Horizontal top, horizontal bottom(Just make an imgination, then you will get it).
And square metals 2 and 3 have just one contact point/node/area, placed next to each other.
The Contact_Area matrix which is there above is fine for one contact point/one contact area. But it is not fine for more than 1 contact areas or points/nodes.
Here are the user-defined function.
function [ L ] = Leitwert_L_1_2(Lambda_1,Lambda_2,A_1_2_H_t, A_1_2_H_b, A_1_2_H_V_f,A_1_2_H_V_ba, A_1_2_V_l, A_1_2_V_r);
% Above function for Square metal 1 and 2
% A_1_2_H_t = Contact area Horizontal top % A_1_2_H_V_ba = Contact area Horizontal/vertical back
% A_1_2_H_b = Contact area Horizontal bottom % A_1_2_V_l = Contact area vertical left
% A_1_2_H_V_f = Contact area Horizontal/vertical front % A_1_2_V_r = Contact area vertical right
function L = Leitwert_L(Lambda_2, Lambda_3, A_2_3 )
% Above function for square metal 2 and 3. Just one contact area. It is fine.
Note: It is just my anticipation formed according to my problem. Why? I have to build the model /write the general code which holds for all model irrespective for matrix size, mateirals and their contact points.
This is my solver.
function LA = Sample_Model
for i=1:n
for j=1:n
LA(i,j) = Leitwert_L_1_2(Lambda(i),Lambda(j), A(i,j), A(i,j),A(i,j),A(i,j),A(i,j),A(i,j)); % bad calling of input arguments here
LA(i,j) = Leitwert_L(Lambda(i), Lambda(j), A(i,j) );
x = LA;
Here I need to let solver know to take the correct function according to the contact points. Leitwert _L_1_2 for six contact points and Leitwert_L for one. It depends on the model, may be there will be three or two or four, or five contacts points or contact areas.
Here also I need help. calling the right function according to number of contact areas.
My problem start from here, How can I allow user to enter the all the contact areas depending on the contacts points between the materials along with just one contact area.
I got an idea, but I don't know how to implement it in the slover.
My idea is to Buid the cell array of contact area matrix like below.
Contact_Area = { 0 [ A_1_2_H_t A_1_2_H_b; A_1_2_H_V_f A_1_2_H_V_ba; A_1_2_V_l A_1_2_V_r] 0;
[A_1_2_H_t A_1_2_H_b; A_1_2_H_V_f A_1_2_H_V_ba; A_1_2_V_l A_1_2_V_r] 0 A_2_3;
0 A_3_2 0};
%I don't know it is a good idea or not. Bcoz, here I need to give some instruction to the user about entering the input arguments for the materials of more than one contact areaa. Like,
%First row for contact area horizontal top and bottom,
%second row for Contact area Horizontal/vertical front and back
%third row for contact area vertical right and left.
This is headache idea according to me! Need suggestion here as well.
And the implementation like below;
function LA = Sample_Model
for i=1:3
for j=3:
% Here I am not getting how to call all the input arguments of Function Leitwert_L_1_2 at a time.
%for ii = 1:6
% for jj = 1:6
LA(i,j) = Leitwert_L_1_2(Lambda(i),Lambda(j), A{i,j}A(ii,jj), A{i,j}A(ii,jj),A{i,j}A(ii,jj),A{i,j}A(ii,jj),A{i,j}A(ii,jj),A{i,j}A(ii,jj)); % I am not sure about the correctness of this %idea
LA(i,j) = Leitwert_L(Lambda(i), Lambda(j), A(i,j) );
x = LA;
Lambda is also a matrix, kindly ignore it. Bcoz I didn't included lots of input arguments to avoid the confusion.
I think that I gave proper explantion of my problem with the examples.
If you still need more explantions, I am ready to give
Any suggestions and answers will be much appreciated.
Thanks in advance.
  1 Comment
Qayray on 23 Jun 2019
I think people would be more willing to help if you inserted the code using the "insert a line of code"-feature (Alt + Enter), this is really hard to follow ;)

Sign in to comment.

Answers (0)




Community Treasure Hunt

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

Start Hunting!