Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Convert Code Containing Global Data to Fixed Point

3 Ansichten (letzte 30 Tage)
Yinyin Zhao
Yinyin Zhao am 1 Apr. 2015
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
Hi, I'm new to use the fixed point converter and HDL coder. I have a problem when I want to convert one of my model function to fixed point because this function is purely defining a global variable "PM" which contains all the parameters in my model. "PM" is a 1*1 structure global variable. I don't know how to convert this function in the fixed point converter. I checked the document for this issue but the situation is a little bit different. I'm using MATLAB 2014b but the document version might be older than this. Also the global variables in the document are not the same data type as mine. So I still can not solve my problems. Basically, my "PM" function is similar the the following, but there are more items in my real function.
%
function [PM]= Parameters(Test)
global PM
%%Constant
PM.R=8.314;
PM.F=96485;
%%Geometry
PM.L=27.6; % Length cm
PM.W=18.5; % Width cm
PM.d=1.47; % Thickness cm
PM.V=PM.L*PM.W*PM.d; % Volume cm
PM.layers=50; %%%%%%%%%%%%%%%Didn't provide%%%%%%%%%%%%%%%
PM.sandwichArea=Test*PM.L*PM.W*PM.layers;
end
Thanks.

Antworten (1)

Kiran Kintali
Kiran Kintali am 2 Mai 2021
Use Persistent Variables instead of Global Variables when translating MATLAB to HDL Code. See doc and best practices in HDL Coder.
web(fullfile(docroot, 'hdlcoder/ug/persistent-variables-1.html?s_tid=doc_srchtitle'))

Diese Frage ist geschlossen.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by