필터 지우기
필터 지우기

Adding #ifdef to the generated C code

조회 수: 22 (최근 30일)
Priya Tejankar
Priya Tejankar 2020년 1월 7일
답변: Rajat Tewari 2020년 1월 10일
I am developing code in MATLAB (m script) and need something like #ifdef to decide whether to execute a function during compilation.
Does something like #ifdef exist for m-script ?

채택된 답변

Rajat Tewari
Rajat Tewari 2020년 1월 10일
You can use exist function for this process along with if else statements to achieve your goal in .m file:
Refer to exist documentation. This is a example of the same for checking if a variable is in workspace or not.
% if variable exists in the workspace
if exist('a') == 0
disp(0)
% if variable doesn't exists in the workspace
elseif exist('a') == 1
disp(1)
end
The same can be checked for files as well.
Hope it helps.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by