学生休息室

分享学生如何在日常项目中使用MATLAB和SIMULINK的技术和现实示例万博1manbetx

实时编辑和实时脚本

At the beginning of preparation for this post, I askedLars Schatkowski,今天的合着者,总结Matlab Live编辑在一个短语中。他似乎期待着这个,并回答:“克里斯托夫,it is actually a new way of coding, because it includes the output of an algorithm to the script itself!” So, no matter how you are using MATLAB today, we think familiarizing yourself with theMatlab Live编辑is beneficial.

顺便说一句,准备内容的所有功劳都归功于Lars。非常感谢!

MATLAB code and report in a single document

Script isn’t just ASCI text anymore but an interactive document that combines MATLAB code, inline output, formatted text, equations, and images in a single environment.

编写MATLAB代码和documenting the outcome at the same time is a great time-saver. I have experienced that project teams with high fluctuation (fancy description for automotive student teams, isn’t it?) have to be good at documenting their know-how or they will become less competitive over time. I imagine that quasi-automated report generation can be a strong asset for longterm success.

在许多功能中,例如,实时编辑器允许:

  • 格式代码和评论就像您使用文字处理器一样
  • 获得生成它的代码旁边的紧凑型输出
  • Intuitively manipulate plots
  • 使用乳胶或方程式编辑器编写方程式

[Click and magnify the images to explore how live editor may look like.]

Embedding a GIF into live editor

Writing equations using LaTeX nomenclature

互动绘图

Jumpstart into analytical equation solving

Live editor is also a powerful user interface to work with equations. They look exactly the same as you would write them with pen on paper. That simplifies finding typos compared to equations represented by ASCI text a lot. Think about your calculus exam and imagine MATLAB differentiating and re-arranging equations for you.Symbolic Math Toolbox™is now tied a lot closer to your MATLAB user interface.

Convert all your code to live scripts?

您现在应该将所有脚本转换为实时脚本吗?您当然可以,但这可能不是最实用的解决方案。首先,对于需要文档的相当一部分的代码,使用实时脚本是有益的!只需考虑加大新团队成员并节省时间即可。其次,考虑一下您将要创建的报告。这些任务通过实时脚本完全从您的盘子中删除。另一方面,为特定目的定义明确定义的脚本或函数可能会保持原样,并且可以从实时脚本中轻松调用。

调试

调试怎么样?不用担心!您仍然可以使用>> DBSTOP,>> DBSTEP和CO。万博1manbetx

我称之为“视觉调试”的新且值得注意的选择。这是理解代码如何工作的一种极为直观的方法。删除某些分号会揭示代码旁边的输出,并且您可以看到与仅在脚本失败后仅查看错误消息相比,错误的发展。

结论

让我再次尝试以单个短语进行总结:没有什么变成负面的,您可以受益很多。

在这里找到一些相关资源的链接:

  • 文档中的示例
  • Release notes随着新功能添加
    • R2016b: Pan, zoom, and rotate axes in output figures. Create and edit equations interactively using the equation editor. Create new sections and format text quickly using auto formatting. Automatically rename all functions or variables in a live script. Drag and drop selected code and text within a live script and between other applications. View outputs sooner when running live scripts
    • R2017a:交互方式编辑包括标题,标签,传说和其他注释的图。获取有关错误的命令和变量的建议。将实时脚本输出复制到其他应用程序。悬停在变量上以查看其当前价值
  • Live Editor in the browser

Feel invited to start and join a discussion. I am curious to learn whether things are applicable to your work and what else you would need.

Cheers Christoph

|

评论

To leave a comment, please click这里to sign in to your MathWorks Account or create a new one.