Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8180763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:17:44+00:00 2026-06-07T00:17:44+00:00

In my model there are an entity generator, some attribute function(out_attrName) and an entity

  • 0

In my model there are an entity generator, some attribute function(out_attrName) and an entity sink. How do I get the sum of all attrName values of every entity? I want to get the value of every entity before it gets to the sink and accumulates this value.

I tried to use a ‘Cumulative Sum’ block but no luck. This block requires discrete time on the input, so I use Discrete-Time Integrator. Can’t say I use it in correct way: for example if values to sum are 34 and 40, the total sum can be some thing like 12344 instead of correct 74.

EDIT:

Example:
consider the following model: 10 entities go to the server and then to the sink.
There are 2 Set attribute blocks:

  • First one for StartTime (current time from Clock, before the server)
  • Second one for EndTime (current time from Clock, after the server)

One Attribute function block to set ServiceTime attribute = EndTime – StartTime.
The model is pretty simple, so ServiceTime attribute is always equal 10. We can see it on the Signal scope.
We’ve got 10 entities. In each entity there is an attribute ServiceTime == 10. Now I want to get sum of ServiceTime attributes for all entities. 10*10=100. How do I do that?

Details:

  1. Model
  2. Set attribute 1
  3. Server
  4. Set attribute 2 & Script function
  5. Get attribute
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T00:17:47+00:00Added an answer on June 7, 2026 at 12:17 am

    After some research here is my own answer that works for me.
    Please comment this answer if I wrong in some point.

    1. We need an accumulator (some storage) to store data. So we need to use MatLab work space for that. We can read/write values from it with functions coder.extrinsic('evalin') and coder.extrinsic('assignin').

    2. We have to put all values from all entities in single vector. After this operation we’ll have data in one place and can do whatever we like to. This vector will be “hosted” by work space.

    3. In my case it’s easy to assign vector elements by index. So there is an ID for every entity (it is the #d value from generator).

    4. Finally, lets write data to vector. Before starting the model, execute this code in Matlab:
      someVar = zeros(1000,1)

    Saving data in Attribute function block right before sink:

    out_EntityDuration = FinishTime - StartTime;
    
    coder.extrinsic('evalin');
    coder.extrinsic('assignin');
    
    x = zeros(1000,1);
    x = evalin('base', 'someVar');
    
    x(Id+1) = out_EntityDuration;
    
    assignin('base','someVar',x);
    

    See more about read/write to workspace here http://www.mathworks.com/matlabcentral/newsreader/view_thread/263578

    After execution the model someVar store data. Now we can find sum or average value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any tool to generate CRUD admin site from Entity Framework Model? Something
Is there any way to use an Entity as a model, and be able
I'm having problems querying the entity model to get additional information. My db has
as per my understanding about mvvm is. there is a model (entity class that
Say I've a user model and there are bunch of user info, like email,
I am working with the output from a model in which there are parameter
is there any way to hold Domain Model's data in Session? in ASP.NET MVC3
Is there a way to check CakePHP's model relationships? One model is saving twice
Is there a way to use the SQL Model (dbml) builder in VS2010 using
is there an easy approach to store my model, which I use with EclipseLink,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.