Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Platform Independence

Subject: Platform Independence

From: Pat Finder

Date: 7 Aug, 2009 02:06:02

Message: 1 of 4

What issues are there when trying to write Matlab code for Mac/Windows OS's?

How do we get around them?

I have a student version, but haven't figured out how to even get Matlab to figure out which OS it is running on.

- Thomas

Subject: Platform Independence

From: Doug Schwarz

Date: 7 Aug, 2009 13:31:47

Message: 2 of 4

In article <h5g26a$o5p$1@fred.mathworks.com>,
 "Pat Finder" <pfinder@netacc.net> wrote:


Hi Thomas,

> What issues are there when trying to write Matlab code for Mac/Windows OS's?

Mostly just file names and any interaction with the OS via the system
function.


> How do we get around them?

Use fullfile instead of hard coding file names. For OS calls you'll
probably have to test for the OS and use a switch or if statement.


> I have a student version, but haven't figured out how to even get Matlab to
> figure out which OS it is running on.

Use

  computer
  ispc
  isunix
  ismac

depending on exactly what you need to know.

--
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.

Subject: Platform Independence

From: Steven Lord

Date: 7 Aug, 2009 13:36:15

Message: 3 of 4


"Pat Finder" <pfinder@netacc.net> wrote in message
news:h5g26a$o5p$1@fred.mathworks.com...
> What issues are there when trying to write Matlab code for Mac/Windows
> OS's?
>
> How do we get around them?
>
> I have a student version, but haven't figured out how to even get Matlab
> to figure out which OS it is running on.

HELP COMPUTER.

--
Steve Lord
slord@mathworks.com

Subject: Platform Independence

From: John D'Errico

Date: 7 Aug, 2009 14:03:05

Message: 4 of 4

"Pat Finder" <pfinder@netacc.net> wrote in message <h5g26a$o5p$1@fred.mathworks.com>...
> What issues are there when trying to write Matlab code for Mac/Windows OS's?
>
> How do we get around them?
>
> I have a student version, but haven't figured out how to even get Matlab to figure out which OS it is running on.
>
> - Thomas

In addition to the tools which can help you decide
which OS you are running under (computer, etc.),
use tools like

pathsep
filesep
fullfile
fileparts

These functions work on ANY system, so they make
your code insensitive to the syste, it runs on. NEVER
use fixed file path delimiters like /.

John

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us