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:
downloading .m files

Subject: downloading .m files

From: LS

Date: 16 Jan, 2013 18:57:08

Message: 1 of 4

Hi,

I'm a teaching assistant for a class that uses Matlab. I need to have the students download .m files that I've written for them and open them in Matlab. I'll write a script on my computer, save it as a .m file, upload it to our class website, and then download it on a new, teaching computer for the students as a .m file (and the final computer on which I downloaded the .m file know it's a Matlab file and labels it as such) but when I open the script it has tons of weird (I think HTML) code on it and it's unusable. I've copied and pasted an example below. I'm writing these scripts on a Mac and the students use PCs, if that matters, but I've also tried resaving the script on a PC, uploading and then re-downloading it and having the same problem. This may be a problem on the University's end with the class website screwing things up, but any help would be much appreciated!

Thank you!

beginning of original script:
%% Section 1: numerical ODE solver
a = 0; % initial value of t
b = 3; % final value of t
c = -1/2; % parameter value
X_zero = 1; % value of X(a); value of X at t=0
dt = 0.1; % arbitrarily small value of dx

for x = a:dt:(b - dt)
  X_zero = X_zero + c * X_zero * dt;
end

how it opens on the download computer:
<!doctype html><html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-us" xml:lang="en-us">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="https://gauchospace.ucsb.edu/courses/theme/standard/styles.php?lang=en_us_utf8" />
<link rel="stylesheet" type="text/css" href="https://gauchospace.ucsb.edu/courses/theme/standard/styles.php?lang=en_us_utf8" />
<link rel="stylesheet" type="text/css" href="https://gauchospace.ucsb.edu/courses/theme/gaucho/styles.php?lang=en_us_utf8" />

<!--[if IE 7]>
    <link rel="stylesheet" type="text/css" href="https://gauchospace.ucsb.edu/courses/theme/standard/styles_ie7.css" />
<![endif]-->
<!--[if IE 6]>
    <link rel="stylesheet" type="text/css" href="https://gauchospace.ucsb.edu/courses/theme/standard/styles_ie6.css" />
<![endif]-->

Subject: downloading .m files

From: Steven_Lord

Date: 17 Jan, 2013 14:17:14

Message: 2 of 4



"LS " <louise.m.stevenson@gmail.com> wrote in message
news:kd6t64$7c$1@newscl01ah.mathworks.com...
> Hi,
>
> I'm a teaching assistant for a class that uses Matlab. I need to have the
> students download .m files that I've written for them and open them in
> Matlab. I'll write a script on my computer, save it as a .m file, upload
> it to our class website, and then download it on a new, teaching computer
> for the students as a .m file (and the final computer on which I
> downloaded the .m file know it's a Matlab file and labels it as such) but
> when I open the script it has tons of weird (I think HTML) code on it and
> it's unusable. I've copied and pasted an example below. I'm writing these
> scripts on a Mac and the students use PCs, if that matters, but I've also
> tried resaving the script on a PC, uploading and then re-downloading it
> and having the same problem. This may be a problem on the University's end
> with the class website screwing things up, but any help would be much
> appreciated!

At a glance, it looks like whatever you're doing to download the file is
saving the whole webpage on which you've posted it, not just the file
itself.

If you've got lots of files to distribute you may want to use the ZIP
function to create a ZIP file, distribute that ZIP file instead of each
individual file, and have the students use the UNZIP function to extract it
to the appropriate folder.

*snip*

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: downloading .m files

From: KIRAN kumar

Date: 17 Jan, 2013 21:48:08

Message: 3 of 4

The answer is simple save the file in a text pad(.txt)
mail it up...
after downloading just click rename and save it with an extension of .m
no need to zip it or do anything else..
hoe this answer will be helpful....

Subject: downloading .m files

From: Josh

Date: 18 Jan, 2013 00:00:09

Message: 4 of 4

"LS" wrote in message <kd6t64$7c$1@newscl01ah.mathworks.com>...
> Hi,
>
> I'm a teaching assistant for a class that uses Matlab. I need to have the students download .m files that I've written for them and open them in Matlab. I'll write a script on my computer, save it as a .m file, upload it to our class website, and then download it on a new, teaching computer for the students as a .m file (and the final computer on which I downloaded the .m file know it's a Matlab file and labels it as such) but when I open the script it has tons of weird (I think HTML) code on it and it's unusable. I've copied and pasted an example below. I'm writing these scripts on a Mac and the students use PCs, if that matters, but I've also tried resaving the script on a PC, uploading and then re-downloading it and having the same problem. This may be a problem on the University's end with the class website screwing things up, but any help would be much appreciated!
>
> Thank you!
>
> beginning of original script:
> %% Section 1: numerical ODE solver
> a = 0; % initial value of t
> b = 3; % final value of t
> c = -1/2; % parameter value
> X_zero = 1; % value of X(a); value of X at t=0
> dt = 0.1; % arbitrarily small value of dx
>
> for x = a:dt:(b - dt)
> X_zero = X_zero + c * X_zero * dt;
> end
>
> how it opens on the download computer:
> <!doctype html><html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-us" xml:lang="en-us">
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
> <link rel="stylesheet" type="text/css" href="https://gauchospace.ucsb.edu/courses/theme/standard/styles.php?lang=en_us_utf8" />
> <link rel="stylesheet" type="text/css" href="https://gauchospace.ucsb.edu/courses/theme/standard/styles.php?lang=en_us_utf8" />
> <link rel="stylesheet" type="text/css" href="https://gauchospace.ucsb.edu/courses/theme/gaucho/styles.php?lang=en_us_utf8" />
>
> <!--[if IE 7]>
> <link rel="stylesheet" type="text/css" href="https://gauchospace.ucsb.edu/courses/theme/standard/styles_ie7.css" />
> <![endif]-->
> <!--[if IE 6]>
> <link rel="stylesheet" type="text/css" href="https://gauchospace.ucsb.edu/courses/theme/standard/styles_ie6.css" />
> <![endif]-->

I have seen this type of thing happen before. Mac's seem to save files in odd ways, and servers sometimes get confused when you try to upload the file.
The best thing to do is to copy the text directly from the editor window, and paste it into a .txt file. Then upload the text file, and have your students copy and paste the contents into a new .m file and name the file as appropriate.
It may seem like some extra work for you, but it is less work than dealing with screwed up files.

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