Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to feed block properties from model

Status
Not open for further replies.

Slowzuki

Mechanical
Mar 27, 2003
137
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
 
Replies continue below

Recommended for you

Set that property to a variable name and feed a value to the variable.
 
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
 
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.
 
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
 
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.
 
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.

 
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.
 
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
 
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
 
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
 
Another tid bit,
"Initialization commands (for masks) cannot access base workspace variables" from Learning Simulink
Ken
 
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.
 
Continuous, I will look into using discrete, but I don't know if the SimMechanics blocks can use discrete.

Ken
 
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.
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor