필터 지우기
필터 지우기

Please Help with Number Arrangement

조회 수: 1 (최근 30일)
DhonXean Bobis
DhonXean Bobis 2015년 4월 1일
댓글: DhonXean Bobis 2015년 4월 2일
Good Day!
I am having a problem regarding arrangement of numbers.
I have a matrix of
[1 2;
2 3;
3 4;
3 5;
4 6;
6 7];
First, I want to find the end node. In this example, 5. Then 5 is connected to 3 and a process will be performed. After that, the program must go to 7 which is connected to 6 and 4. when the program detects that the number is 4 it will stop and another operation will be performed.
Please help me. Any tips will do.
Thanks
Regards Dhon Xean
  댓글 수: 2
John D'Errico
John D'Errico 2015년 4월 1일
편집: John D'Errico 2015년 4월 1일
Totally confusing. You tell us that 5 is connected to 3. Then it goes to 7. How does that happen? How can we know what you are doing if you do not explain it?
I am tempted to look at the matrix as a set of undirected edges in a graph. But if we start at node 5, then go to 3, why is not the NEXT step to node 4 or to node 2, as both of those nodes seem to be connected to node 3.
You need to explain your problem clearly, else it becomes impossible to answer.
DhonXean Bobis
DhonXean Bobis 2015년 4월 2일
Sorry for the vague question
Currently, I am working on a forward/backward sweep method for power systems.
The method specified was that you need to start from the end node. The example data i gave was for the sending node and receiving node, column respectively.
Node 7 was an end node connected to 6, which was a junction node. After evaluating processes, 6 and 7 are connected, then another function going to node 4, I need to evaluate other end nodes, for example, node 5 and if it detects that it is on a junction node, here node 3, another process will be performed.
Thanks and sorry for the vague question.
Regards Dhon Xean

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

채택된 답변

Joep
Joep 2015년 4월 1일
Do you mean something like this?
prompt = 'What is your test value? \n';
TestNo=input(prompt); %Test No.
a=[1 2;
2 3;
3 4;
3 5;
4 6;
6 7];
b= a(:,2)==TestNo; %Location
c=a(b,1);
d= a(:,2)==c;
if d == zeros(size(d))
if c == 4;
msgbox('another program will start');
end
else
e= a(d,1);
if e == 4;
msgbox('another program will start');
end
end
  댓글 수: 1
DhonXean Bobis
DhonXean Bobis 2015년 4월 2일
After evaluating this code. I think it will be a big help.
Thank you very much.
And sorry for the vague question.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Variables에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by