필터 지우기
필터 지우기

Simulink matlab function block with two outputs, can't make it work

조회 수: 13 (최근 30일)
Charalampos Loukas
Charalampos Loukas 2017년 6월 5일
댓글: Charalampos Loukas 2017년 6월 8일
I've got the following problem. I run a simulation which extract an array called Iabc to workspace. I use then a function which takes as an input this array and have as outputs the fault location and an error. I would like to use a matlab function block inside simulink that will run the function and will show the fault location and the error in two displays. However, the function to work has to wait simulation to finish in order to get this array to work. I dont know how to do that. Any ideas?
The code of the function is:
function[location,er]=fault(Iabc)
Iaa=Iabc(:,1);
Ibb=Iabc(:,2);
Icc=Iabc(:,3);
.
.
.
location=((2.89*10^5)*td*10^-6)/2;
actual_fault=get_param('two_remotes/Distributed Parameters Line','Length');
k=str2num(actual_fault);
er=abs(location-k);
end
I want to work like that, to take as input the array.
%
  댓글 수: 1
Charalampos Loukas
Charalampos Loukas 2017년 6월 5일
It gives error when simulating like: Index expression out of bounds. Attempted to access element 2. The valid range is 1-1. More information
Function 'MATLAB Function' (#142.60.61), line 3, column 12: "2" Launch diagnostic report.

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

답변 (1개)

Don Zheng
Don Zheng 2017년 6월 8일
Your input seems to be a column vector and your MATLAB function is asking for the second and the third columns from the input. If the input only have three elements, try just Iaa=Iabc(1); Ibb=Iabc(2); Icc=Iabc(3);

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by