solving a quartic using simulink
조회 수: 3 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
채택된 답변
Walter Roberson
2011년 8월 7일
MuPad provides matlabFunction() that can generate MATLAB code. You would then use a MATLAB Block if I recall.
추가 답변 (1개)
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Manual Performance Optimization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!