Hello,
Can I use this equation as input at Simulink? I would appreciate any help.
Simulink block:

 採用された回答

Walter Roberson
Walter Roberson 2015 年 12 月 24 日

0 投票

Use a MATLAB Function Block, or an Interpreted MATLAB Block

5 件のコメント

Walter Roberson
Walter Roberson 2015 年 12 月 25 日
The interpreted version might be okay.
For the non-interpreted version you would need a few extra lines to initialize the output sizes correctly because of the way that memory allocation is handled for MATLAB Function Block.
Walter Roberson
Walter Roberson 2015 年 12 月 27 日
You would use a random number block if your inputs are random, but if you want to load the variables from the workspace then use a From Workspace block.
Bob
Bob 2015 年 12 月 29 日
編集済み: Bob 2016 年 3 月 9 日
Sorry for bothering you again.
I load my variables from workspace.
"t" 1x1001 double, "Amp" 1000x1 double, "Omega" 1000x1 double & "Psi" 1000x1 double.
simin = [t,Amp,Omega,Psi]
"Error due to multiple causes."
"Inner matrix dimensions must agree."
"Error while evaluating expression."
Walter Roberson
Walter Roberson 2015 年 12 月 29 日
"Interpreted MATLAB Function
Supports only a single input and a single output port. Use a Mux block to combine the inputs and a Demux block to separate the outputs if you pass multiple signals into or out of these blocks."
Alternately you could use a Level 2 MATLAB S-Function as those accept multiple inputs.
For the Interpreted MATLAB Function, I am not at the moment sure whether it is permitted to name the input anything other than u. It might need to look something like,
sum( u(:,2).*cos(2.*pi.*u(:,3).*u(:,1)+u(:,4) )
But since this is a scalar result involving only values from your workspace, it is not clear to me why you do not just calculate the scalar in MATLAB ? Is your mention of a random number generator intended to be a hint that you want to try random phases? Keep in mind that if you use random numbers inside an algebraic loop then the calculation is not going to be differentiable and Simulink would not be able to calculate consistent values.
Bob
Bob 2016 年 1 月 2 日
Thank you for your answer again.
So I should calculate the equation in Matlab.
Get two variables simin=[t,h].
And use "From Workspace" block at Simulink?
Actually I did that. I got the same results with Matlab. The only "problem" is that I have to manually change the simulation time in Simulink but it's ok.
Thanks for your time.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

タグ

質問済み:

Bob
2015 年 12 月 24 日

編集済み:

Bob
2016 年 3 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by