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