I have made several matrics where I tried to read a txt file. I want to perform the below problem I have mentioned. Help is required.

2 visualizaciones (últimos 30 días)
Suppose I have a circuit like this below image
here A is activating B and B is activating C.
For this circuit Matrix be like
source node
A B C
-------------------------------------------
A | 0 0 0
Target B | 1 0 0
node C | 0 1 0
That means j th elements are controling i th elements. If A is activating B then there is 1. If A was inhibiting B there will be -1 in the matrix. And the type of the link for inhibition would be like this ---| .
In the above code upto this matrix formation is done.
I want to creat separate .topo file for seperate matrics should be store in separate folder according to there number. And the text file should be in this format I am mentioning below.
Source Target Type
A B 1
B C 1
1 signifies activation
2 signifies inactivation
how can do this part of coding?
Attemped code:
----------------------------
A=readtable('topo.txt')
for iter=1:size(A,1)
vec(:,:,iter)=[A{iter,2:4};A{iter,5:7};A{iter,8:10}];
end
disp(vec);
Input text file:
1,0,-1,-1,0,0,-1,0,0,0
2,0,-1,-1,0,0,0,0,0,0
3,0,-1,-1,0,0,0,0,1,0
4,0,-1,0,0,0,-1,-1,0,0
5,0,-1,0,0,0,-1,0,0,0
6,0,-1,0,0,0,-1,1,0,0
7,0,-1,0,0,0,0,-1,1,0
8,0,-1,0,0,0,0,0,-1,0
9,0,-1,0,0,0,0,0,1,0
10,0,-1,0,0,0,0,1,-1,0
11,0,-1,0,0,0,0,1,0,0
12,0,-1,0,0,0,0,1,1,0
13,0,-1,0,0,0,1,0,0,0
14,0,-1,0,0,0,1,1,0,0
15,0,-1,1,0,0,0,0,0,0
16,0,-1,1,0,0,0,0,1,0
17,0,-1,1,0,0,1,0,0,0
18,0,0,0,0,0,0,1,1,0
19,0,0,0,0,0,1,1,0,0
20,0,0,0,1,0,0,1,0,0
21,0,0,0,1,0,0,1,1,0
22,0,0,1,1,0,0,0,1,0
  1 comentario
Walter Roberson
Walter Roberson el 13 de Abr. de 2021
1,0,-1,-1,0,0,-1,0,0,0
2,0,-1,-1,0,0,0,0,0,0
If I understand that correctly, the first line says that line 1, B inhibits A and C inhibits A, B inhibits C; and the second line says Line 2, B inhibits A and C inhibits A.
If I undestand correctly, that should lead to output
Source Target Type
B A 2
C A 2
C B 2
Source Target Type
B A 2
C A 2
Is that correct? Is that all there is to it?

Iniciar sesión para comentar.

Respuestas (1)

Shadaab Siddiqie
Shadaab Siddiqie el 16 de Abr. de 2021
From my understanding you want to find the index of the matrix with source and target nodes which follows certain condition (for example: there value is 1). Here is an example to show how you can you find() function to get the index of a matrix with certain condition and get the nodes values.
>> M = [0 1 0; 1 0 0; 0 0 1]; % source and target matrix
>> m1 = ["A" "B" "C"]; % maping the names of nodes
>> [row,col] = find(M==1); % get all index with i->j
>> m1(row)
ans =
1×3 string array
"B" "A" "C"
>> m1(col)
ans =
1×3 string array
"A" "B" "C"

Categorías

Más información sobre Install Products en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by