matlab-coder

Solving ODEs inside a Subsystem in Simulink

梦想与她 提交于 2020-12-10 07:20:18
问题 I'm trying to figure out how to solve a system of ODEs inside a subsystem in a Simulink model. Basically, each call to this subsystem, which happens at each tick of the simulation clock (fixed-step), entails solving the ODEs. So there's like a different "clock" for the subsystem. I have an M-file that implements the function for the system of ODEs. Currently, I have a MATLAB Function block for that. It needs a lot of parameters that I can get from the base workspace (via evalin and using

Matlab coder: “All inputs must be constant”

浪子不回头ぞ 提交于 2020-02-25 06:28:06
问题 I'm using Matlab Coder to convert this code to C++: fs = 50; [b,a] = butter(3,0.5/(fs/2),'high'); ... % Other code using fs Then, I get this error: "All inputs must be constant". If I do: [b,a] = butter(3,0.5/(50/2),'high'); , it works. I found this post: Constants and Matlab Coder So I tried: fs = 50; [b,a] = coder.const(@butter,3,0.5/(fs/2),'high'); But it still reports the same error. How can I fix this? 回答1: Define Class Properties with Constant Values In ConstInput.m classdef ConstInput

Get Errors when running Simulink block, but get Success when running respective M-file alone

随声附和 提交于 2020-01-15 19:16:51
问题 I would like to transmit an encoded image using USRP. The first step is to load the image using Matlab and encode it. The respective codes are shown as follows. function msg = genMsg1 %#codegen persistent msgStrSet count; if isempty(msgStrSet) count = 0; msgStrSet = imread('cameraman.tif'); % Load the image of cameraman.tif end msgtemp = dec2bin(msgStrSet); % Covert msgStrSet into binary value msg_1ine = msgtemp(count+1,:).'; % Take msgtemp line by line and tranpose it msg = str2num(msg_1ine)

Get Errors when running Simulink block, but get Success when running respective M-file alone

青春壹個敷衍的年華 提交于 2020-01-15 19:16:14
问题 I would like to transmit an encoded image using USRP. The first step is to load the image using Matlab and encode it. The respective codes are shown as follows. function msg = genMsg1 %#codegen persistent msgStrSet count; if isempty(msgStrSet) count = 0; msgStrSet = imread('cameraman.tif'); % Load the image of cameraman.tif end msgtemp = dec2bin(msgStrSet); % Covert msgStrSet into binary value msg_1ine = msgtemp(count+1,:).'; % Take msgtemp line by line and tranpose it msg = str2num(msg_1ine)

How to convert matlab function 'pchip' to c code with matlab coder

我们两清 提交于 2020-01-06 07:25:23
问题 I have a problem with Matlab Coder. I would like to generate C code from Matlab interpolating function pchip . I verified the function with coder.screener and it says it's available for code generation but when I try to build pchip.m file I get this error: The function 'pchip' is not supported for standalone code generation. See the documentation for coder.extrinsic to learn how you can use this function in simulation. Can anyone help me? I really need to convert this function in C for a

IntelliSense error identifier “emlrtStack” is undefined

风流意气都作罢 提交于 2019-12-25 02:34:48
问题 I am converting a MATLAB written function into C by "Matlab coder". After I get the converted files , the converted function always have first input argument as const emlrtStack *sp . Now when I am trying to test it on VC++ 2013, IntelliSense is giving mentioned above error. I manually tried to locate this identifier in emlrt.h file but no such thing is present there. I tried to convert a simple multiply function with two input arguments[like, c=mul(a,b) ] but still the converted function has

MATLAB Compiler vs MATLAB Coder

隐身守侯 提交于 2019-12-17 08:25:33
问题 What's the difference between the two? As far as I understand it, MATLAB Compiler wraps the MATLAB code into a .exe file so that it can be used without installing MATLAB, and only requires the MCR. On top of it MATLAB Builder NE can also be used to produce .Net assemblies to be used with .Net framework instead of the .exe file, but they still require MCR. Now I don't understand what MATLAB Coder used for? It generates C/C++ code. But is the MATLAB code really converted into C/C++, or is it

MATLAB Compiler vs MATLAB Coder

无人久伴 提交于 2019-12-17 08:25:14
问题 What's the difference between the two? As far as I understand it, MATLAB Compiler wraps the MATLAB code into a .exe file so that it can be used without installing MATLAB, and only requires the MCR. On top of it MATLAB Builder NE can also be used to produce .Net assemblies to be used with .Net framework instead of the .exe file, but they still require MCR. Now I don't understand what MATLAB Coder used for? It generates C/C++ code. But is the MATLAB code really converted into C/C++, or is it

undefined reference to `rtIsNaN'

你。 提交于 2019-12-13 00:06:14
问题 I am trying my hands with Matlab coder. I wrote a simple matlab script and generated the C-code (along with the necessary headers) for the same. The matlab script looks like this : function amin_idx=findminidx(a)%#codegen amin_idx=find(a==min(a),1,'first'); In the Matlab coder, I start a new project, pre-condition a as a 10x1 vector and build the project to generate the .c and .h files. The I write a new .c file containing the main() which is as follows : #include<stdio.h> #include "rt

MATLAB: MEX matrix division gives different result than m-file

陌路散爱 提交于 2019-12-12 18:41:43
问题 I've used MATLAB's coder tool to create a MEX version of the matrix exponential function, to be used in another set of functions. The issue is, the MEX version gives different results than the original m-file. After debugging it, I believe that the reason this is, is because the MEX file and the m-file do not do matrix division (\) the same. Or the MEX file has issues with it in the first place. All the variables leading up to the line where the matrix division occurs are equivalent on both