Complex Data type not accepted in Simulink
显示 更早的评论
Hello Everyone, I am having an issue with the interaction of matlab function block in the simulink with my model block. Below you can also find the picture.
I have created a matlab function with three inputs and 1 output. Since in the matlab function block, i have solved an differential equation, it has complex expressions in the form of for example .
(exp(sqrt(-a/b)))
This generates the output of complex data type from the function block. When passing this to the integrator which is the input to my plant, I cannnot run the simulink due to the error
"Cannot pass the complex value to non-complex location"
I tried chaning the data types of integrator, then the same thing happens to other blocks in the simulink.
I also tried using absolute values, which ofcourse gives real number, but turns out to be very large numbr and genrates high magnitude. I really need help in solving this issue.
Can anyone help me in this/
Thanks in advance.

7 个评论
Prateek Tiwari
2020-6-1
Walter Roberson
2020-6-1
"I have created a matlab function with three inputs and 1 output. "
"When passing this to the integrator"
"I am doing a simlation for platoon of vehicles."
The integrator block in Simulink remembers the previous state. Therefore if you have a platoon of N vehicles, you cannot simply stream N signals from the function block into the integrator to get N integrated values: you would need N such integrators so that each of the N remembers the state properly.
If you vectorize the task so that your function takes 3*N inputs and has N outputs, then you can express the MATLAB equivalent of integrating each seperately as
temp = repmat({tf(1, [1 0]}, 1, N);
integrate_all = blkdiag(temp{:}); [1/s, 0, 0, 0, ...; 0, 1/s, 0, 0, 0, ...0, 0, 1/s, 0, 0, ...]
and the state-space equivalent of this turns out to be:
A = zeros(N,N);
B = eye(N);
C = eye(N);
D = zeros(N,N);
which should be easy to initialize in simulink.
Prateek Tiwari
2020-6-1
Prateek Tiwari
2020-6-1
Walter Roberson
2020-6-1
In past post, Mathworks employees say that if you need to use an integrator with complex values, then seperate real and complex parts and integrate them seperately. You indicated that you tried that but the coefficients got large. If you have a rotary motion, then the information about wrapping values on the Integrator page might help.
Walter Roberson
2020-6-1
There is no configuration setting for the integration block in particular or Simulink in general to have it be happy about complex inputs to the integration, nor to have it accept such inputs with a warning.
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Simulink 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!