×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to feed block properties from model

How to feed block properties from model

How to feed block properties from model

(OP)
If there is a block with a property in it's mask such as phase in a sine block, how do you feed a value in from the model?

Thanks,
Ken

RE: How to feed block properties from model

Set that property to a variable name and feed a value to the variable.

RE: How to feed block properties from model

(OP)
The problem is how to I feed a variable from the model.  I have tried using blocks sending the variable to the work space, tried the from tag both cause an error saying the the variable is undefined.

Ken

RE: How to feed block properties from model

If you want the model to feed the variable, then obviously the model has to supply the variable value.  It can't come from the workspace.

RE: How to feed block properties from model

(OP)
But HOW do I feed a model output into a variable? I've been trying to figure this out for a long time!  What block can I use to do this! Please let me know! Thanks!

Ken

RE: How to feed block properties from model

If you can't understand this rather simple answer, then I suggest you buy a couple of books on Matlab and Simulink and start reading and learning how these tools work.

RE: How to feed block properties from model

(OP)
Lewish, not to be rude but I understand what I need to do, not how, I have a Simulink text and have read through hours of online help!

I can output the variable to the Matlab workspace using the to workspace block which I assumed would work as ALL variables exist in the model automatically exist in the Matlab workspace.  But it does not work.  I have used the workspace to define a variable for a model but I cannot get the model to fill the variable correctly.

If you know the name of the block which can do this correctly please let me know, if you would like to continue to make fun of my poor Simulink skills when letting me know feel free, I don't mind.  I just really would like to learn this.

If you feel I should learn on my own, could you at least give a hint of terminology Mathworks uses to describe this?  To me it should be a simple task, I'm obviously missing something.

RE: How to feed block properties from model

OK, here's another hint.  Forget the workspace.  Just because the model sends the variable info "to workspace" doesn't mean it is visible to everything in the model. Also, a variable defined in the workspace is not automatically available to the model.  It is only available to the workspace and the command line.

Any block you create can have an output variable defined for it, assuming it has an output.  Look at masking a block to see how this is done.

I am not making fun of your skills, I am saying you are looking too hard at the trees and not seeing the forest.

By the way, what version of Matlab are you using.  If it is older than 6.0, then I can understand some of your confusion.  It was poorly explained in the earlier versions.

I have spent 6 years learning Matlab, and feel I only know about 25% of it capability.  It is something you must use constantly and keep trying new things, or you will never get proficient in it.

I hope this helps.  Keep working at it and you will succeed.

RE: How to feed block properties from model

(OP)
Ok, I have now spent 4 hours reading everything I could get my hands on regarding filling a variable without exiting Simulink and I'm no further ahead.

I can't find any way to unmask a sine source to adjust what variables are visible through the translation that occurs in the mask. I can put another mask on top and play with that but I cannot see how that helps me at all.

I'm just going to make my own block to generate a sine input and not mask the i/o.

I have encountered this problem before in defining the axis for an actuator in a SimMechanics model and had to resort to using direction cosines and body actuators to resolve the forces.

If I ever discover how I will post back here.

Ken

RE: How to feed block properties from model

(OP)
Below is my hint, it is all I could find probing the Mathworks archives for another hour.  95% of the responses to Q's similiar to mine say it cannot be done.  This bit is all I could find:

>to create a (dummy) subsystem block in the model that has >mask initialization code that uses 'evalin' to put the >parameters from the database into the base workspace or >uses setparam to set values in other blocks.

It is for passing database info in an out of a mask. I will try and find out more.
Ken

RE: How to feed block properties from model

(OP)
I have reread this thread and reviewed what I have learned, if Lewish could comment it would help.

-The sine block in particular doesn't not accept variables passed to it as it is a source block(Mathworks newsgroup archive)

I still think it should work!

-I did pick up on your hint to look at block properties and used the Simulink internal variable name extracted from the model to input to the sine block. It chokes saying the variable is already in use.  This confuses me as the sine block should not need to fill the variable, only read it.

Still working on it but no success.
Ken

RE: How to feed block properties from model

(OP)
Another tid bit,
"Initialization commands (for masks) cannot access base workspace variables" from Learning Simulink
Ken

RE: How to feed block properties from model

Are you simulating in continuous mode or descretized mode?

It makes a big difference in what you can and can't do.  I very seldom do anything in continuous mode.

RE: How to feed block properties from model

(OP)
Continuous, I will look into using discrete, but I don't know if the SimMechanics blocks can use discrete.

Ken

RE: How to feed block properties from model

Oh, now I see why you are having problems.

The SimMechanics Toolset is a brand new release, and they don't have all the bugs out of it yet.

When you said "sine block", I assumed you were using either the one from "Signals" or the one in the SimPowerBlockset, which have far greater functionality.

My appologies, but here is another example of posters not providing adequate information about their problem, when asking for help.

I suggest you contact the Mathworks Technical Support Service for help.

RE: How to feed block properties from model

(OP)
Thank-you Lewish, I will try contacting them again.  I tried not to post too much info as the same problem can occur with just a Sine Source block, scope and constant when doing a continuous solution (which is what I was doing my troubleshooting with)

The SimMechanics blocks are interfacing with the std Simulink blocks via special blocks in its library.

Point taken about details.
Ken

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close