solving a quartic using simulink

1 回表示 (過去 30 日間)
Amir Khan
Amir Khan 2011 年 8 月 7 日
回答済み: Sulaymon Eshkabilov 2019 年 5 月 4 日
Hi, I have a general quartic equation. I have solved it in maple and Mupad both but I want to create a block in simulink so that when I provide different values of the coefficients to the block, it gives me the solution of that quartic equation for that particular set of coefficients. Can somebody help? Thanks in advance.

採用された回答

Walter Roberson
Walter Roberson 2011 年 8 月 7 日
MuPad provides matlabFunction() that can generate MATLAB code. You would then use a MATLAB Block if I recall.
  2 件のコメント
Amir Khan
Amir Khan 2011 年 8 月 8 日
Thanks Walter! Can you tell me how can I do that? Im new to it and struggling with it
Amir Khan
Amir Khan 2011 年 8 月 8 日
Got it! thanks!

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

その他の回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2019 年 5 月 4 日
Hi,
Here are the steps to model a simple quadratic equation:
% Step 1. Drag and drop three [Constant] blocks into your Model window for a, b, c whose values you can define directly in each block, or via workspace (MATLAB command window), or via Model properties:==> File ->Model Properties -> Callbacks ->IntitFcn: a = ???; b= ???; c =???;
% Step 2. Drag and drop [Display] block into your Model window.
% Step 3. Drag [MATLAB Function] block and double click on it. Write the following two lines of code in the opened M-file editor and save it:
function y = fcn(a, b, c)
y=roots([a, b, c]);
% Step 4. When you save your fcn() file - M-file editor saves your Simulink model. Now, your [MATLAB Function] block will have three input ports for [a], [b],[c], respectively.
% Step 5. Connect three [Constant] block with the [MATLAB Function] block and output port of it with [Display] block. Now the model is complete, BUT it has a problem with the output data size.
% Step 6. Click on Model Explorer (Ports and Data Manager) -> [MATLAB Function] -> y Output -> Enter: 2 in size and put a tick mark on Variable Size option -> hit [Apply].
% Step 7. Hit [Run] and have fun ... :) . See the screenshot of the complete model and its results shown here.
% Note: Solver of your model has to be set at "Fixed Step". By default the Simulink model solver is set at "Variable Step" solver option.

カテゴリ

Help Center および File ExchangeManual Performance Optimization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by