Mex error while running a code matlab 2021a
    5 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
Hi, i'm new to matlab so i can't figure out where the error is. Could somone tell me how I can rectify it
I'm using this code which sombody had already made.
Thanks in advance
function Create_Data()
% This function creates the model data depicted in Figure 4-6 of
%
% Characterization of K-Complexes and Slow Wave Activity in a Neural Mass Model
% A Weigenand, M Schellenberger Costa, H-VV Ngo, JC Claussen, T Martinetz
% PLoS Computational Biology. 2014;10:e1003923
% Move to source folder(assuming it contains the Figures folder
cd ..;
% Check if the executable exists and compile if needed
if(exist('Cortex_mex.mesa64', 'file')==0)
    mex CXXFLAGS="\$CXXFLAGS -std=c++11 -O3" Cortex_mex.cpp Cortical_Column.cpp;
end
% Add the path to the simulation routine
addpath(pwd);
% Go back into figures folder
cd Figures;
% Time series
Data_Time_Series(1);
Data_Time_Series(2);
% Time series
Data_Stimulation();
end
First I got this error 
>> Create_Data
Building with 'MinGW64 Compiler (C++)'.
Error using mex
g++: error: \-fexceptions: No such file or directory
So, I put D:\MatlabFiles\cortex_mex.cpp
>> D:\MatlabFiles\cortex_mex.cpp
 D:\MatlabFiles\cortex_mex.cpp
   ↑
Invalid use of operator.
But it still said this
0 Kommentare
Antworten (1)
  Lokesh
      
 am 30 Mai 2024
        Hi akshara,
It appears that the first issue is related to a compiler flag error when trying to compile a C++ file using the 'mex' function.
As a workaround, adjust the 'mex' command in your MATLAB function by ensuring no backslash precedes '-fexceptions'.
mex CXXFLAGS="$CXXFLAGS -std=c++11 -O3" Cortex_mex.cpp Cortical_Column.cpp;
Refer to this MATLAB Answer for more information:
The second issue involves trying to directly run a C++ file in MATLAB and incorrectly using a file path as a command. MATLAB does not support the direct execution of C++ files. Instead, C++ code must be compiled into a MEX file using the 'mex' command. Additionally, typing a file path directly into the MATLAB Command Window as a command, such as 'D:\MatlabFiles\cortex_mex.cpp', is not a valid operation. If you are trying to change the current working directory to where your files are located, use the cd command followed by the path, like 'cd D:\MatlabFiles'.
Refer to the following documentation for more information on 'mex' function:
0 Kommentare
Siehe auch
Kategorien
				Mehr zu MATLAB Compiler SDK finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

