MATLAB Answers

0

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

Asked by Sansit Das on 23 Oct 2019
Latest activity Commented on by 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.

2 Answers

Answer by Daniel M
on 23 Oct 2019
Edited by Daniel M
on 23 Oct 2019
 Accepted Answer

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:

  1 Comment

Thank you Daniel for your answer. This would really help me in running my codes. Thanks a lot.

Sign in to comment.


Answer by Bjorn Gustavsson on 23 Oct 2019

Have a look at the commands: computer, ispc, insunix, ismac.
HTH

  1 Comment

Sign in to comment.