필터 지우기
필터 지우기

ERROR: Python in Simulink: Class mismatch for variable 'commandOut'. Expected 'double', Actual 'char'.

조회 수: 2 (최근 30일)
I get an error while Running a Python Script in a Simulink Model
function y = Test_1(a,k)
coder.extrinsic('tic','toc', 'system','clear' ,'clc','num2str' );
commandStr = ['C:\LegacyApp\Python27\python sqd.py ',num2str(a),' ',num2str(k)];
[status, commandOut] = system(commandStr);
y = coder.nullcopy(zeros(size(a),'double'));
y=commandOut;
This is the Error which i got during compilation:
Class mismatch for variable 'commandOut'. Expected 'double', Actual 'char' .

답변 (1개)

Robert Snoeberger
Robert Snoeberger 2015년 3월 10일
commandOut , the second output argument from system , is a char array. See the doc . You used num2str to convert to char arrays from the variables a and k . Similarly, you need to convert to double from commandOut . You may be able to use str2num .
If you are using R2014b or newer, then you can call Python from MATLAB .

카테고리

Help CenterFile Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by