MATLAB How to Suppress Output in MATLAB Using eval()?

  • Thread starter Thread starter matematikawan
  • Start date Start date
  • Tags Tags
    Matlab Output
AI Thread Summary
To suppress output in MATLAB while assigning variables in a loop, use a semicolon at the end of the assignment statement. The provided code snippet creates 12 magic squares without displaying them by appending a semicolon after the eval function. This ensures that MATLAB performs the assignments silently, allowing for variable creation without cluttering the command window with output. The discussion references a previous thread for additional context on the topic.
matematikawan
Messages
336
Reaction score
0
I get this example from >>help eval
and add a semicolon.for n = 1:12
eval(['M' num2str(n) ' = magic(n)']);
end

The above commands display all 12 magic square. How do I suppress the output? I only want MATLAB to assign the variables not display them.
 
Last edited:
Physics news on Phys.org

Similar threads

Replies
5
Views
2K
Replies
2
Views
2K
Replies
3
Views
3K
Replies
5
Views
3K
Replies
4
Views
1K
Replies
2
Views
3K
Replies
2
Views
2K
Back
Top