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:
string to control instrument

Subject: string to control instrument

From: Daphne

Date: 13 Jan, 2008 20:33:01

Message: 1 of 2


I am trying to control an serial instrument through Matlab
and one of the functions calls for a:
fprintf(1,'1LMP 40')
where the 40 is a value that I set the instrument to. Now
if I am reading the value from a GUI and want to use
['1LMP ', num2str(val)] this errors out.
Also, if I try to create the correct string before hand (a
= ''1LMP 40''; and then use it, it errors out.

Any ideas how to 'feed' the info into this command?

Thanks,
Daphne

Subject: string to control instrument

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 14 Jan, 2008 00:25:13

Message: 2 of 2

In article <fmdsht$hdr$1@fred.mathworks.com>,
Daphne <daphnew_too_nospam@yahoo.com> wrote:

>I am trying to control an serial instrument through Matlab
>and one of the functions calls for a:
>fprintf(1,'1LMP 40')
>where the 40 is a value that I set the instrument to. Now
>if I am reading the value from a GUI and want to use
>['1LMP ', num2str(val)] this errors out.
>Also, if I try to create the correct string before hand (a
>= ''1LMP 40''; and then use it, it errors out.

>Any ideas how to 'feed' the info into this command?

"this errors out" and "it errors out" are not specific enough
for us to figure out what issues you are facing.

If you have fetch val from a GUI, then val would probably be
a string rather than a numeric value. Perhaps num2str(val) is
leading to an error because val is already a string? If so then

['1LMP ' val] would form the string you need.


The code you give,
a = ''1LMP 40'';
uses incorrect syntax for a string.
a = '1LMP 40';

--
We regret to announce that sub-millibarn resolution bio-hyperdimensional
plasmatic space polyimaging has been delayed until the release
of Windows Vista SP2.

Tags for 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