Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
importing values to simulink!

Subject: importing values to simulink!

From: hari

Date: 29 Nov, 2010 11:37:03

Message: 1 of 4

Hi,
I have a designed a starter motor in simulink,
in which i need to give variable load torque as input.
for that i had created a excel with 75 input values.
I do not know how to give these values as input to the dc motor.
I had tried with constant, i had imported the excel to workspace.
but its taking all the 75 values at a time and showing error.
Instead I need it to take one value at a time and give result in the scope.
for each and every value i need to get a plot in the same scope.

Subject: importing values to simulink!

From: Arkadiy Turevskiy

Date: 29 Nov, 2010 16:03:05

Message: 2 of 4

"hari " <rhn.engg@lucastvs.co.in> wrote in message <id038v$dkk$1@fred.mathworks.com>...
> Hi,
> I have a designed a starter motor in simulink,
> in which i need to give variable load torque as input.
> for that i had created a excel with 75 input values.
> I do not know how to give these values as input to the dc motor.
> I had tried with constant, i had imported the excel to workspace.
> but its taking all the 75 values at a time and showing error.
> Instead I need it to take one value at a time and give result in the scope.
> for each and every value i need to get a plot in the same scope.

You need tu use the block "From Workspace" and define its input variable ( called simin by default).

One way to do it is to define a time vector, for example:
>>time=linspace(0,10,75)'; % a column of 75 time values linearly distributed between 0 and 10 seconds

Now your variable torque load. If you have it in Excel, import it to MATLAB, and make sure its size is 75 by 1. If you load variable is called "load", do:
>>size(load)
and make sure you get

75 1
as an answer. If you get " 1 75", then transpose it by doing
>>load=load';

now create input matrix:
>>simin=[time load];
>>size(simin) %check that you get 75 by 2
  
Your simulation should run now.

Subject: importing values to simulink!

From: Arnaud_Miege

Date: 30 Nov, 2010 22:42:10

Message: 3 of 4



"hari " <rhn.engg@lucastvs.co.in> wrote in message
news:id038v$dkk$1@fred.mathworks.com...
> Hi, I have a designed a starter motor in simulink,
> in which i need to give variable load torque as input.
> for that i had created a excel with 75 input values.
> I do not know how to give these values as input to the dc motor.
> I had tried with constant, i had imported the excel to workspace.
> but its taking all the 75 values at a time and showing error.
> Instead I need it to take one value at a time and give result in the
> scope.
> for each and every value i need to get a plot in the same scope.

Yes, a constant is a constant, not a signal that varies with time, therefore
Simulink is treating your 75 values as a constant vector with 75 elements.
You also need 75 values of time that correspond to your load torque input
values. Once the data is imported in MATLAB, use the from workspace block
and parameterize with the time and signal values, e.g. [time_values
load_torque_values].

HTH,

Arnaud

Subject: importing values to simulink!

From: hari

Date: 6 Dec, 2010 07:48:04

Message: 4 of 4

"Arnaud_Miege" <amiege@mathworks.com> wrote in message <id3uk2$l81$1@fred.mathworks.com>...
> tks

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us