Suppressing result using 'varname_' in Matlab

  • MATLAB
  • Thread starter Heidis
  • Start date
  • Tags
    Matlab
In summary, the conversation discusses a problem with the output of a loop in Matlab, specifically with the use of the 'varname_' function. The individual is trying to prevent the result from being written in the command window multiple times and has tried using two ;; but received an error. They are seeking help in correcting their mistake and are concerned about the lack of response.
  • #1
Heidis
2
0
Hey everybody
I have very recently learned the function 'varname_' for storing data with different names in a loop. My problem is that the result is written in the command window even though I have written ;.

My command looks like this

for run=237:273
[F,dt] = Dataimport(n,run);
eval(['F_' num2str((run-237)*10) '=F']);
clc
end

Since every F comming out of the function Dataimport is a 10x33,877 matrix I would very much like to stop Matlab from writing it 37 times (length of loop).

I have tried putting two ;; but that gave an error. Right now I'm just deleting the result for each loop but it still takes a lot of unnecessary power.

Can anyone help me and correct my mistake?

Regards Heidi
 
Physics news on Phys.org
  • #2
How should I interpret the lak of response? Is it because you don't know how to solve the problem, maybe because this is just how Matlab has decided to do it, or because you cannot see why I'm even having this proplem?
Please let me know this as my script is increasing with more of these huge loops with new variables.
Regards Heidi
 
  • #3
Instead of:

eval(['F_' num2str((run-237)*10) '=F']);

Try:

eval(['F_' num2str((run-237)*10) '=F;']);

Note the ; after F.
 

Related to Suppressing result using 'varname_' in Matlab

1. How can I use 'varname_' to suppress results in Matlab?

The 'varname_' syntax in Matlab allows you to suppress the output of a variable or expression in the command window. Simply add an underscore after the variable or expression you want to suppress, and the output will not be displayed.

2. Can I suppress multiple variables using 'varname_'?

Yes, you can suppress multiple variables or expressions by adding an underscore after each one. For example, "var1_ var2_ var3_" will suppress the output of all three variables.

3. Will suppressing results using 'varname_' affect my code?

No, using 'varname_' will not affect the functionality of your code. It only suppresses the output in the command window and does not change the values of the variables or expressions.

4. Can I use 'varname_' in a script or function?

Yes, you can use 'varname_' in both scripts and functions. It will suppress the output in the command window when the script or function is executed.

5. Is there an alternative to using 'varname_' to suppress results in Matlab?

Yes, you can also use a semicolon (;) at the end of a line to suppress the output of a specific line of code. This will only suppress the output of that line, whereas 'varname_' will suppress the output of the entire line or expression.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
10K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
Back
Top