MATLAB Enter key is executing code

15 ビュー (過去 30 日間)
Bryan Yu
Bryan Yu 2021 年 5 月 15 日
コメント済み: dpb 2021 年 5 月 15 日
I thought enter is supposed to just do a line break, and ctrl+enter runs the code. I'm running the 2020b version, and everytime I press enter, the program line breaks AND executes the code. How can I change that, so it's the same as most coding programs and the on-ramp?
Thanks,
  1 件のコメント
dpb
dpb 2021 年 5 月 15 日
>> ver
-----------------------------------------------------------------------------------------------------
MATLAB Version: 9.9.0.1592791 (R2020b) Update 5
...
I've never messed with the Live Editor before, but I don't see such a symptom here...<Enter> acted normally; <Ctrl-Enter> did (eventually) execute the code had typed; was quite a bit of latency...
I don't see anything in Preferences that would appear to be to make such behavior an option.
I suppose this behavior holds across MATLAB sessions?

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

回答 (1 件)

Jan
Jan 2021 年 5 月 15 日
編集済み: Jan 2021 年 5 月 15 日
Do you mean the command window? You cannot change this. If a command is complete, it is executed when enter is pressed.
The command window is not the right location to create code. Write a script or a function instead in the editor. The Ctrl-Enter behavior was introduced in the live script due to the lack of a separate editor. Generations of Matlab users are familiar with this behavior since 25 years.
Use a live script to get the live script behaviour.
  1 件のコメント
dpb
dpb 2021 年 5 月 15 日
I never even thought about the command window, Jan...that's just so natural.

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

カテゴリ

Help Center および File ExchangeSoftware Development Tools についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by