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.

 Respuesta aceptada

Guillaume
Guillaume el 5 de Feb. de 2018

2 votos

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 comentario

Mark
Mark el 5 de Feb. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 5 de Feb. de 2018

Comentada:

el 5 de Feb. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by