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.

 採用された回答

Guillaume
Guillaume 2018 年 2 月 5 日

2 投票

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 件のコメント

Mark
Mark 2018 年 2 月 5 日
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.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Get Started with MATLAB についてさらに検索

製品

質問済み:

2018 年 2 月 5 日

コメント済み:

2018 年 2 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by