I have had several students submit files that consisted of automatically generated MATLAB code that consisted of only the variables in the workspace. The files look something like
% -------------------------------------------------------------------
% Generated by MATLAB on 1-Feb-2018 11:28:15
% MATLAB version: 9.2.0.556344 (R2017a)
% -------------------------------------------------------------------
a = 8;
b = 12;
t = [0 0.1 0.2 0.30000000000000004 0.4 0.5 0.6 0.7 0.8 0.9 1];
x = 2;
y = [2 2.31 2.64 2.99 3.3600000000000003 3.75 4.16 4.59 5.0400000000000009 ...
5.51 6];
z = 6;
How are they generating this code? I've looked everywhere and can't figure it out. The assignment was to turn the diary on, type in some sample MATLAB commands (and hopefully learn something from them), turn diary off and then turn in the resulting file. I understand what happens when they generate a .mat file, but not the file above.

 Réponse acceptée

Guillaume
Guillaume le 5 Fév 2018

2 votes

Right click in the workspace browser, select save (or simply press CTRL+S instead of these two steps), then select MATLAB Script (*.m) as the save type. Matlab will automatically create a script to recreate your workspace.

1 commentaire

Mark
Mark le 5 Fév 2018
Thank you, that is it. That isn't even close to anything I taught my students to do. They find all kinds of creative ways to mess up their homework.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with MATLAB dans Centre d'aide et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by