Main Content

sbiolasterror

SimBiology last error message

Syntax

sbiolasterror
diagstruct = sbiolasterror
sbiolasterror([])
sbiolasterror(diagstruct)

Arguments

diagstructThe diagnostic structure holding Type, Message ID, and Message for the errors.

Description

sbiolasterror or diagstruct = sbiolasterror return a SimBiology® diagnostic structure array containing the last error(s) generated by the software. The fields of the diagnostic structure are:

Type 'error'
MessageID The message ID for the error (for example, 'SimBiology:ConfigSetNameClash')
Message The error message

sbiolasterror([]) resets the SimBiology last error so that it will return an empty array until the next SimBiology error is encountered.

sbiolasterror(diagstruct) will set the SimBiology last error(s) to those specified in the diagnostic structure (diagstruct).

Examples

This example shows how to use verify and sbiolasterror.

  1. Import a model.

      a = sbmlimport('radiodecay.xml')
     a = 
    
       SimBiology Model - RadioactiveDecay 
    
       Model Components:
         Compartments:      1
         Events:            0
         Parameters:        1
         Reactions:         1
         Rules:             0
         Species:           2
         Observables:       0
  2. Change the ReactionRate of a reaction to make the model invalid.

      a.reactions(1).reactionrate = 'x*y'
    
    a = 
    
       SimBiology Model - RadioactiveDecay 
    
       Model Components:
         Compartments:      1
         Events:            0
         Parameters:        1
         Reactions:         1
         Rules:             0
         Species:           2
         Observables:       0
  3. Use the function verify to validate the model.

      a.verify
    
    Error using SimBiology.Model/verify
    --> Error reported from Expression Validation:
    Name 'y' in reaction 'Reaction1' does not uniquely refer to any species, parameters, or
    compartments according to SimBiology precedence rules.
  4. Retrieve the error diagnostic struct.

      p = sbiolasterror
    p = 
    
      struct with fields:
    
             Type: 'Error'
        MessageID: 'SimBiology:ReactionObjectDoesNotResolve'
          Message: 'Name 'y' in reaction 'Reaction1' does not uniquely refer to any species, parameters, or compartments according to SimBiology precedence rules.↵'
    
  5. Reset sbiolasterror.

    sbiolasterror([]);
    
    
  6. Set sbiolasterror to the diagnostic structure p.

    sbiolasterror(p);
    

Introduced in R2006a