How to find the execute but don't display output syntax of a loop?

7 ビュー (過去 30 日間)
Lina Baquero
Lina Baquero 2012 年 11 月 28 日
回答済み: Steven Lord 2025 年 2 月 25 日
Hi, i have this problem: Let A_ij =ij-j^2 for all i,j {1.2...10}
Im using this for loop:
for i=1:10
for j=1:10
A(i,j)=i*j-j^2
end
end
However I need to find a way to do the for loop without displaying the result each step. In other words, find the execute but don't display output syntax.
I don't know how to do it.
  3 件のコメント
Jan
Jan 2012 年 11 月 28 日
Such basic details are explained in the Getting Started chapters of the doucmentation. You cannot use such a powerful tool as Matlab without reading the documentation.
Isabella
Isabella 2025 年 2 月 25 日
編集済み: Isabella 2025 年 2 月 25 日
its not that deep Jan

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

回答 (3 件)

Sabarinathan Vadivelu
Sabarinathan Vadivelu 2012 年 11 月 28 日
for i=1:10
for j=1:10
A(i,j)=i*j-j^2;
end
end
Use semicolon at the end of the statements to suppress the output

Vishal Rane
Vishal Rane 2012 年 11 月 28 日
Use ';' at the end of a statement. It suppresses the display of output on the command window.
In your case
A(i,j)=i*j-j^2;
Refer Link for more information.

Steven Lord
Steven Lord 2025 年 2 月 25 日
FYI, this wasn't available when the question was originally asked but as of release R2024b you can tell MATLAB to stop whenever a command would display unsuppressed output. This lets you locate missing semicolons in a potentially long segment of code. The Editor will let you specify you want to "Pause on Unsuppresed Output" (see the "Error Breakpoints" section on this documentation page) if you prefer using the graphical interface to using the command-line debugging tools.

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by