MATLAB Answers

A switch case statement that will help me to either run codeS in Windows or linux, based on whichever OS it is

2 views (last 30 days)
Sansit Das
Sansit Das on 23 Oct 2019
Commented: Sansit Das on 23 Oct 2019
I want to write a switch case statement that will help me to either run my code in Windows or linux, based on whichever OS it is. Any Suggestions!

  0 Comments

Sign in to comment.

Accepted Answer

Daniel M
Daniel M on 23 Oct 2019
Edited: Daniel M on 23 Oct 2019
if ismac
% Code to run on Mac platform
elseif isunix
% Code to run on Linux platform
elseif ispc
% Code to run on Windows platform
else
disp('Platform not supported')
end
And you can easily adapt that to a switch if you like.
Taken from this page:

Translated by