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:
Editing options

Subject: Editing options

From: Maxx Chatsko

Date: 8 Jul, 2010 17:05:04

Message: 1 of 5

Hello all,
   On my quest for Matlab success I ran into an obstacle. I call a certain function in my code that has an input "options", which can be used to specify parameters within the function. Problem is, I cannot get the option I need. I tried just about everything, so I think its just syntax. The code is below.

Description of function:
GSSpcWrite (filename, spectra, axis, logtxt, logbin, options)

Input parameters:
% - filename: the name of the file in which the spectrum will be
% written, path included
% - spectra: (double array) the spectral data itself. Spectral data are in
% a matrix, where one row represents one spectrum.
% - axis: (cell array), the xaxis of the spectra.
% - logtxt: (char array or cellstring array) logtext to save with the spectra
% - logbin: (uint8 data) binary data to save with the data
=================================================
% - options: optional parameter: structure: possible fields:
% fcmnt: string: file comment
% fexper: integer: experimental technique: see SPC file format
% description (0 = general)
% fsource: string: instrument source
% fmethod: string: used methods, instrumental techniques, ...
% xunit: integer: type of x-units: see SPC file format
% description (0 = general)
% yunit: integer: type of y-units: see SPC file format
% description (0 = general)
% SaveHighPrecision: spectra are stored in float32 format as
% standard (as should be the case). When higher precision is
% needed, however, the spectra will be processed and stored as
% integer values. To use the highest precision, set this value
% to 1.
====================================================
I need to change the xunit parameter, but nothing I try works. Any ideas?
             Thanks all
Do I need to include more code/further explanation?

    

Subject: Editing options

From: Steven Lord

Date: 8 Jul, 2010 17:30:35

Message: 2 of 5


"Maxx Chatsko" <chatskom@chemimage.com> wrote in message
news:i150g0$cjg$1@fred.mathworks.com...
> Hello all,
> On my quest for Matlab success I ran into an obstacle. I call a certain
> function in my code that has an input "options", which can be used to
> specify parameters within the function. Problem is, I cannot get the
> option I need. I tried just about everything, so I think its just syntax.
> The code is below.
>
> Description of function:
> GSSpcWrite (filename, spectra, axis, logtxt, logbin, options)

*snip*

> % xunit: integer: type of x-units: see SPC file format
> % description (0 = general)

*snip*

> I need to change the xunit parameter, but nothing I try works. Any ideas?
> Thanks all
> Do I need to include more code/further explanation?

Yes to your second question -- post the code you tried to use to call this
function and the code you used to try to construct the options struct array
that you used in that call and indicate what happened when you executed your
call (error? warning? MATLAB crash?)

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Editing options

From: Maxx Chatsko

Date: 8 Jul, 2010 17:57:06

Message: 3 of 5

"Steven Lord" <slord@mathworks.com>

> > Description of function:
> > GSSpcWrite (filename, spectra, axis, logtxt, logbin, options)
> > xunit: integer: type of x-units: see SPC file format
> > description (0 = general)

> Yes to your second question -- post the code you tried to use to call this
> function and the code you used to try to construct the options struct array
> that you used in that call and indicate what happened when you executed your
> call (error? warning? MATLAB crash?)

   No errors, warnings, or anything happened when I called the function - just perfect execution (except for the change I wanted of course). The function GSSpcWrite is from a toolbox acquired from Ghent University. We had to fix other things in their code as its not the cleanest toolbox. Difficult to track due to the high number of functions...

This is the SPC file format from above. Its a subfunction that gets the X-axis type. I need 'nanometers':
function Types = GetSPCAxisTypes (reversed)
Types.X{1,1} = '0';
Types.X{1,2} = 'Arbitrary';
                                       ...etc
Types.X{4,1} = '3';
Types.X{4,2} = 'Nanometers';

I used the following code as part of a "save" option on my GUI, which saves the converted SPC file from GSSpcWrite:
               xunit=3;
               GSSpcWrite(fci_spc,SUPER_FCI,WL_FCI,xunit); %Save FCI data as .spc file
...
   I've tried integers, strings, arrays,...I've included 'options' preceding 'xunit'. I've tried to get the handle to the Types function. Idk what else to do but play around and hope for the best. Thanks for your time.
              Maxx

Subject: Editing options

From: Steven Lord

Date: 8 Jul, 2010 18:50:26

Message: 4 of 5


"Maxx Chatsko" <chatskom@chemimage.com> wrote in message
news:i153hi$33n$1@fred.mathworks.com...
> "Steven Lord" <slord@mathworks.com>
>
>> > Description of function:
>> > GSSpcWrite (filename, spectra, axis, logtxt, logbin, options)
>> > xunit: integer: type of x-units: see SPC file format
>> > description (0 = general)
>
>> Yes to your second question -- post the code you tried to use to call
>> this function and the code you used to try to construct the options
>> struct array that you used in that call and indicate what happened when
>> you executed your call (error? warning? MATLAB crash?)
>
> No errors, warnings, or anything happened when I called the function -
> just perfect execution (except for the change I wanted of course). The
> function GSSpcWrite is from a toolbox acquired from Ghent University. We
> had to fix other things in their code as its not the cleanest toolbox.
> Difficult to track due to the high number of functions...
>
> This is the SPC file format from above. Its a subfunction that gets the
> X-axis type. I need 'nanometers':
> function Types = GetSPCAxisTypes (reversed)
> Types.X{1,1} = '0';
> Types.X{1,2} = 'Arbitrary';
> ...etc
> Types.X{4,1} = '3';
> Types.X{4,2} = 'Nanometers';
>
> I used the following code as part of a "save" option on my GUI, which
> saves the converted SPC file from GSSpcWrite:
> xunit=3;
> GSSpcWrite(fci_spc,SUPER_FCI,WL_FCI,xunit); %Save FCI data
> as .spc file

Note that the help text you provided in your initial post indicated that the
options input should be the _sixth_ input to the function and should be a
_struct array_ (which you can create using the STRUCT function.) You're
passing in xunit as a _double_ as the _fourth_ input to the function, which
means GSSpcWrite will treat it as the "logtxt" input. Modify your call to
use the correct number and ordering of inputs and to use an options struct
array with a field xunit containing the value 3.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Editing options

From: Maxx Chatsko

Date: 8 Jul, 2010 19:38:09

Message: 5 of 5

"Steven Lord" <slord@mathworks.com>

    Yeah I have it as the 6th, my bad just a typo. The struct works...it doesn't give me nanometers as it is assigned to 3 in their function, but I found the error in their code where it reassigns the value. I can take it from here. Thanks for your help and time =)
        Maxx

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