Suppress function output

前端 未结 3 1077
南旧
南旧 2020-12-19 11:57

I have a short function which uses textscan to read data into a variable.

My problem is that I always get this:

>>function(\'funct         


        
3条回答
  •  青春惊慌失措
    2020-12-19 12:23

    The simplest way to avoid having output printed out is to not assign the first output argument if no output argument was requested:

    function [aOut,b,c] = doSomething
    
    %# create a,b,c normally
    a = 1;
    b = 4;
    c = 3;
    
    %# only assign aOut if any output is requested
    if nargout > 0
       aOut = a;
    end
    

提交回复
热议问题