Main Content

hasdata

Determine if simulink.cloud.MultisimDatastore has data available to read

Since R2026a

    Description

    tf = hasdata(mds) returns logical 1 if the datastore mds contains unread data available to be read. Use this function to determine if further calls to read will return new data. When mds does not have data available to read, hasdata returns 0. If you want to re-read the data, move the read position back to the start using reset.

    Examples

    collapse all

    Create a simulink.cloud.MultisimDatastore object and read the simulation results.

    Suppose you have already created a simulink.multisim.DesignStudy object and have a cloud cluster. Use the batchsim function with the design study object to launch a simulation on a cloud cluster.

    cloudClusterURL = "yourcluster.example.com";
    cloudCluster = simulink.cloud.addCluster('myCloudCluster',cloudClusterURL);
    job = batchsim(cloudCluster,designStudy);

    Create a datastore using multisimDatastore to fetch and store the simulation results from the simulink.cloud.Job object.

    mds = multisimDatastore(job);

    You can check if the datastore has unread data using hasdata. The while loop iterates through the entire datastore and the read function reads the simulation results for each simulation.

    while hasdata(mds)
      simOut = read(mds);
    end
    

    You can reset the read position of the datastore using reset and start reading again from the first set of simulation results.

    reset(mds)
    data = read(mds);

    Input Arguments

    collapse all

    Datastore to read, specified as a simulink.cloud.MultisimDatastore object.

    Output Arguments

    collapse all

    Data availability indication, returned as a 1 or 0 of data type logical. When the simulink.cloud.MultisimDatastore object has data that has not yet been read, tf is 1. When data is not available, tf is 0.

    Data Types: logical

    Version History

    Introduced in R2026a