필터 지우기
필터 지우기

Simulink Error "Attempt to extract field 'p1' from 'mxArray'"

조회 수: 36 (최근 30일)
Dave Russell
Dave Russell 2021년 11월 4일
답변: Jere Knuutinen 2024년 8월 6일
I'm creating a parabolic curve fit then trying to send the parameters to another function block. It works in Matlab, but when I put it into function block
function coefficients = my_block(Start, Steps, Setpoint)
coder.extrinsic('fit');
%#codegen
coefficients = [0;0;0];
x = [0; Steps; Steps*2];
y = [Start; Setpoint; Start];
f = fit(x,y,'poly2');
coefficients(1) = f.p1;
coefficients(2) = f.p2;
coefficients(3) = f.p3;
I get the error above. Simple fix?

답변 (2개)

Swatantra Mahato
Swatantra Mahato 2021년 11월 8일
Hi Dave,
The output of the extrinsic function 'fit' would be an mxArray, which is likely leading to the error when trying to extract 'p1' in the line
coefficients(1) = f.p1;
You can refer to the following link to work with output of an extrinsic function
Hope this helps

Jere Knuutinen
Jere Knuutinen 2024년 8월 6일
Did you find solution for this problem?

카테고리

Help CenterFile Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by