Skip to content
Snippets Groups Projects
Select Git revision
  • 010e48ecafd5485270c475c7e4b93b1790af78b5
  • master default protected
2 results

module3_wrapup.m

Blame
  • vand's avatar
    vand authored
    010e48ec
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    module3_wrapup.m 442 B
    %% module 3, example - short-circuit operators
    
    name = 'Vedrana';
    %name = '';
    
    % I want to check if the name starts with 'Ved'. But what if name has less than
    % 3 letters? I need to make sure that name[:3] is not evaluated if name is too 
    % short. I add the first condition and &&. The second condition will not be
    % evaluated if the first is false.
    
    if numel(name)>3 && all(name(1:3)=='Ved')
        disp('Cool')
    else
        disp('Not so cool')
    end