f

#### Modify tunable global parameters in 'C' S-Function

I am creating a Simulink model with a large number of parameters.  I would like for the values of these parameters to be reconfigurable after deployment (i.e., after code generation and binary executable distribution) via a human-readable configuration file.  My reasons for wanting to change these values in the field are due to changes in sensors and external environments as well as debugging in actual hardware.

I have created a 'C' S-Function which parses my configuration file and auto-magically determines the names, types and values of the tunable parameters.  My issue is with regards to getting these values into the model.  I can dynamically create lots of output ports and use lots of data stores, but that method doesn't seem ideal.  Is there a way that I can parse through existing Simulink model workspace parameters, compare them to config file parameters and set them?  I also need to create the S-Function once and not have to modify it when additional parameters are added to the model / configuration file.

I got something like 'mexEvalString("param = [1 2 3]");' to work in Simulation, but I can't generate code as long as that line is included (unspecified error).

I suppose my questions are 3 fold:
1.  Can I parse and modify global tunable Simulink parameters from within a C S-Function
2.  Am I going about this the wrong way?  What is standard practice for this type of thing?

I've been searching quite a bit, but haven't come across a solution yet.
Thanks!

 0
tomasu (3)
5/2/2012 7:48:05 PM
comp.soft-sys.matlab 211264 articles. 25 followers. lunamoonmoon (257) is leader.

5 Replies
577 Views

Similar Articles

[PageSpeed] 46

Are you deploying to a machine with MATLAB/Simulink installed on it or not?

I assume not, but if you are then have a look at the RSIM target and tuning parameters by specifying required parameters in a .mat file.

If not, then you're going about it in a non-standard way (although you may be able to get it to work).
Typically the model (without your S-Function) would be set-up to have its parameters defined as being imported extern (via the inline parameters options).
Then the generated code would be wrapped in code that does the definition of those parameters.
That can be done automatically through the tmf (template make file) in a similar way to how the grt target sucks in grt_main.c.

Phil.

 0
phil986 (332)
5/3/2012 5:46:16 PM
Thanks for the informative response Phil!

You are correct in guessing that I am not deploying to a machine with MATLAB/Simulink installed.

Members of my team really "want" to be able to build the final output binary directly from Simulink, without needing to modify any C wrapper or S-Function (even if the number of tunable parameters has changed).  I have been making the case for building the output in a C environment with a wrapper.

Do you know of any means to auto-generate a  structure from Simulink that I can parse through in order to find out what the external inline parameters are dynamically, so that the wrapper can remain the same even if the model is changed?  I have a test project working now, but I am still defining the values myself using the C API.

I looked into your TMF suggestion today, but wasn't able to figure out how to auto-generate C code that would define the values.

Thanks Again!
- Tom

"Phil Goddard" <phil@goddardconsulting.ca> wrote in message <jnug98$hdc$1@newscl01ah.mathworks.com>...
> Are you deploying to a machine with MATLAB/Simulink installed on it or not?
>
> I assume not, but if you are then have a look at the RSIM target and tuning parameters by specifying required parameters in a .mat file.
>
> If not, then you're going about it in a non-standard way (although you may be able to get it to work).
> Typically the model (without your S-Function) would be set-up to have its parameters defined as being imported extern (via the inline parameters options).
> Then the generated code would be wrapped in code that does the definition of those parameters.
> That can be done automatically through the tmf (template make file) in a similar way to how the grt target sucks in grt_main.c.
>
> Phil.

 0
tomasu (3)
5/7/2012 9:41:06 PM
I'd write a MATLAB script to do most of the work.

It would
1. interrogate the model to determine what parameters need to be defined.
2. read the data file and extract the required parameters from it
3. generate a c file containing the required structure of data
4. build the model, ensuring that the c file generated in step 3 is included in the process.

Phil.

"Tom" wrote in message <jo9fhi$n3o$1@newscl01ah.mathworks.com>...
> Thanks for the informative response Phil!
>
> You are correct in guessing that I am not deploying to a machine with MATLAB/Simulink installed.
>
> Members of my team really "want" to be able to build the final output binary directly from Simulink, without needing to modify any C wrapper or S-Function (even if the number of tunable parameters has changed).  I have been making the case for building the output in a C environment with a wrapper.
>
> Do you know of any means to auto-generate a  structure from Simulink that I can parse through in order to find out what the external inline parameters are dynamically, so that the wrapper can remain the same even if the model is changed?  I have a test project working now, but I am still defining the values myself using the C API.
>
> I looked into your TMF suggestion today, but wasn't able to figure out how to auto-generate C code that would define the values.
>
> Thanks Again!
> - Tom
>
> "Phil Goddard" <phil@goddardconsulting.ca> wrote in message <jnug98$hdc$1@newscl01ah.mathworks.com>...
> > Are you deploying to a machine with MATLAB/Simulink installed on it or not?
> >
> > I assume not, but if you are then have a look at the RSIM target and tuning parameters by specifying required parameters in a .mat file.
> >
> > If not, then you're going about it in a non-standard way (although you may be able to get it to work).
> > Typically the model (without your S-Function) would be set-up to have its parameters defined as being imported extern (via the inline parameters options).
> > Then the generated code would be wrapped in code that does the definition of those parameters.
> > That can be done automatically through the tmf (template make file) in a similar way to how the grt target sucks in grt_main.c.
> >
> > Phil.

 0
phil986 (332)
5/9/2012 3:27:07 AM
> It would
> 1. interrogate the model to determine what parameters need to be defined.
> 2. read the data file and extract the required parameters from it
> 3. generate a c file containing the required structure of data
> 4. build the model, ensuring that the c file generated in step 3 is included in the process.

Just to clarify on steps 2 and 3, I'd generate C code that allowed a new data file to be read (checking that it had the correct parameters in it) so that the data in the data structure could be changed on the fly in the field.

Phil.

 0
phil986 (332)
5/9/2012 6:09:09 PM
Hi Phil,

Just wanted to say that your suggestion was very interesting.  I spent a day or so playing around with some Matlab scripting before finally deciding that the automated searching, parsing and setting of Simulink parameters was not worth the significant effort.

Mathworks code generation is limited with regards to file IO, etc.  I plan on using "SimpleIni" for the inputing the parameter values.  Short of dynamically coding C files with fwrite in a Matlab script, I don't see a workable solution.  FYI - my plan is to either:

1.  Use basic S-Functions with output ports and build the model from Simulink, being careful to test the connections.
2.  Bring the simulink code gen output into a C development environment to build it with a wrapper (my preference).

Thanks again for the help.  It's great to know there are such helpful people on the interwebs!

- Tom C.

"Phil Goddard" <phil@goddardconsulting.ca> wrote in message <joebs5$a43$1@newscl01ah.mathworks.com>...
>
> > It would
> > 1. interrogate the model to determine what parameters need to be defined.
> > 2. read the data file and extract the required parameters from it
> > 3. generate a c file containing the required structure of data
> > 4. build the model, ensuring that the c file generated in step 3 is included in the process.
>
> Just to clarify on steps 2 and 3, I'd generate C code that allowed a new data file to be read (checking that it had the correct parameters in it) so that the data in the data structure could be changed on the fly in the field.
>
> Phil.

 0
tomasu (3)
5/17/2012 6:58:27 PM

Similar Artilces:

Output returned by S-function 'xxxxxxx' in 'xxxxx/S-Function' during flag=3 call must be a real vector of length 1
Hi there, I've found several posts where people are experiencing this error "Output returned by S-function 'xxxxxxx' in 'xxxxxxx/S-Function' during flag=3 call must be a real vector of length 1" but I haven't been able to access a definitive solution. My m-files ran successfully with my previously installed version of Matlab/Simulink (i think V12 from 2000) but I've just upgraded to 2011a and now see this error. in InitializeSizes(u): sizes.NumOutputs = 1; sizes.NumInputs = 2; in Output(t,u): if u(2) == 0 u(2) = 1; end sys = u(1)/u(2); Does anyone have any hints? Is there a new syntax? cheers, Mel "Mel Cutler" <melcinasia@yahoo.co.nz> wrote in message news:iq7t6t$2ld$1@newscl01ah.mathworks.com... > Hi there, > > I've found several posts where people are experiencing this error > "Output returned by S-function 'xxxxxxx' in 'xxxxxxx/S-Function' during > flag=3 call must be a real vector of length 1" but I haven't been able to > access a definitive solution. > > My m-files ran successfully with my previously installed version of > Matlab/Simulink (i think V12 from 2000) but I've just upgraded to 2011a > and now see this error. > > in InitializeSizes(u): > sizes.NumOutputs = 1; > sizes.NumInputs = 2; > > in Output(t,u): > if u(2) == 0 > u(2) = 1; > end > sys = u(1)/u(2); > > Does anyone...

'^=' and '~='?
Hello, What is the difference between '^=' and '~='? Thanks, Duckhye ...

Scilab's 'optim' and 'splin'
I've got this really cool application that makes a smoothed line using splines, then fits it to a source line using a nonlinear weighting. I'm currently using SciLab with it's 'optim' and 'splin' function to do this, but now I need to write some embeddable C++ code. The 'splin' function is obvious -- it generates a spline from a number of inflection points. The 'optim' function as I am using it uses a quasi-Newton method, which is working just fine for me. Before I go and write this stuff up by hand, does anyone have any suggestions on where I can find example code to do this? I'm mostly concerned with the optimization -- I'd like to get my hands on something where some one else has already fallen into the pitfalls. TIA. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Posting from Google? See http://cfaj.freeshell.org/google/ "Applied Control Theory for Embedded Systems" came out in April. See details at http://www.wescottdesign.com/actfes/actfes.html Just a remark : there is a lsq_splin function which try to fit a splin to discrete points (with various weight if needed). May be it can help you at least to find a good starting point for your optimization ? hth Bruno Tim Wescott wrote: > I've got this really cool application that makes a smoothed line using > splines, then fits it to a source line using a nonlinear weighting. Is it important that you u...

'''''''''''''The Running Update/Append Queries Using VBA code Ordeal''''''''''''''
Hello fellow programmers, I am trying to run an append/update query from code, a command button on a form initiates the queries. the format i am using is; _____________________________________________________ SELECT "criteria" FROM "criteria" WHERE "criteria" UPDATE/APPEND "field selections" RecordSource "qryExample" = above text strings" _______________________________________________________________________ When i am running a SELECT query in this manner it works fine with no problems, and accepts the values of specified linked form fields. This never works when doing an APPEND/UPDATE query. It can never find the values of linked form fields, Access always asks for the parameter value of the field(s) in question, or Access comes up with an error 3323 - No recordset. I am sure there are other people that have had this problem. What is the difference between Select queries and append/update queries? the append/update queries never seem to be able to find values in linked form fields. Can anyone shed any light on this or point to a knowledgebase Item, or even recommend a book focusing on this subject, I will go and buy it now. I have been for up 2 nights trying to acomplish this and now considering suicide, please help. Thanks In advance, Aaron. I know of two ways you can accomplish this. 1. You can create the SQL script for you append or update query and run the script with DoCmd.RunSQL. 2. You can create a...

1 to 20 with x number of 1's, 2's, 3's, ... 20's
This is probably a simple thing to do, so perhaps someone would send me in the right direction. I need to generate a list containing numbers from 1 to 20, say. But I cant just use A = 1:20, for example, because that provides me only one instance of each of the values. What I need is X instances for each value. For example, 5 ones, twos, threes, and so forth. Is there a simple command for this? Regards, Ulrik. On Sep 9, 10:52=A0am, "Ulrik Nash" <u...@sam.sdu.dk> wrote: > This is probably a simple thing to do, so perhaps someone would send me i= n the right direction. > > I need to generate a list containing numbers from 1 to 20, say. But I can= t just use A =3D 1:20, for example, because that provides me only one insta= nce of each of the values. What I need is X instances for each value. For e= xample, 5 ones, twos, threes, and so forth. > > Is there a simple command for this? > > Regards, > > Ulrik. x=3D5; %for example desiredlist=3Dreshape(ones(x,1)*[1:20],1,20*x) hth, suresh "Ulrik Nash" <uwn@sam.sdu.dk> wrote in message <i6aaol$pvr$1@fred.mathworks.com>... > This is probably a simple thing to do, so perhaps someone would send me in the right direction. > > I need to generate a list containing numbers from 1 to 20, say. But I cant just use A = 1:20, for example, because that provides me only one instance of each of the values. What I need is X instances for e...

MATLAB's SOUND() function in C
Is there a way to implement MATLAB's sound function under C? For those who don't use MATLAB, it's essentially a simplistic, static, mono sound function that converts a series a numbers into a sound at a given sampling rate. nothing fancy. all the Sound APIs begin by discussing all the fancy drivers and buffers and crazy shit i don't really care about. Thanks. In article <1151779016.882805.282580@d56g2000cwd.googlegroups.com>, sluox@yahoo.com wrote: > Is there a way to implement MATLAB's sound function under C? > > For those who don't use MATLAB, it's essentially a simplistic, static, > mono sound function that converts a series a numbers into a sound at a > given sampling rate. nothing fancy. all the Sound APIs begin by > discussing all the fancy drivers and buffers and crazy shit i don't > really care about. > > Thanks. The basic thing to do is: - SndNewChannel - SndDoCommand to send a bufferCommand - SndDisposeChannel If you intend to play the sound asynchronously, be careful to not dispose the sound channel or the buffer you play before the sound has finished playing (install a callback using SndDoCommand, if you want to be informed when that is) For more info, take a look at the function SndSnip_PlaySoundResourceUsingBufferCmds in SoundSnippets.c (<http://developer.apple.com/samplecode/soundsnippets/listing1.html>). Reinder Reinder Ver...

Any XL C/C++'s option to determine the compiler's predefined macros
Hi, AIX 5.3 $xlc++ -qversion IBM XL C/C++ Enterprise Edition V8.0 for AIX Version: 08.00.0000.0014 Is there any XL C/C++'s option to determine the compiler's predefined macros? Alex Vinokur In article <2e672e57-f577-4134-9e81-03eb6b3097b7@35g2000pry.googlegroups.com>, Alex Vinokur <alexvn@users.sourceforge.net> writes: > Hi, > > AIX 5.3 > >$ xlc++ -qversion > IBM XL C/C++ Enterprise Edition V8.0 for AIX > Version: 08.00.0000.0014 > > Is there any XL C/C++'s option to determine the compiler's predefined > macros? > > Alex Vinokur They are defined in /etc/vac.cfg: -D_AIX,-D_AIX32,-D_AIX41,-D_AIX43,-D_AIX50,-D_AIX51,-D_AIX52,-D_AIX53,-D_IBMR2,- -D_POWER but somehow I suspect this is not quite what you are looking for. On Jan 14, 1:47=A0pm, m.krae...@gsi.de (Michael Kraemer) wrote: > In article <2e672e57-f577-4134-9e81-03eb6b309...@35g2000pry.googlegroups.= com>, > > Alex Vinokur <ale...@users.sourceforge.net> writes: > > Hi, > > > AIX 5.3 > > > $xlc++ -qversion > > IBM XL C/C++ Enterprise Edition V8.0 for AIX > > Version: 08.00.0000.0014 > > > Is there any XL C/C++'s option to determine the compiler's predefined > > macros? > > > Alex Vinokur > > They are defined in /etc/vac.cfg: > > -D_AIX,-D_AIX32,-D_AIX41,-D_AIX43,-D_AIX50,-D_AIX51,-D_AIX52,-D_AIX53,-D_= IB=ADMR2,- > -D_POWER > > but some... error C2440: 'return' : cannot convert from 'const char *' to 'const unsigned short *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast Hi , I was trying to build my project in VC with latest Service Packs but got this error . C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlconv.h(125) : error C2440: 'return' : cannot convert from 'const char *' to 'const unsigned short *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast I am using some ATL functionality ( String conversion) In Preprocessor setting I have made UNICODE and _UNICODE , but no change in error . Any help is highly solicited . Thanks, Abhijit "Abhijit Bhadra" <abhijit.bhadra@ca.com> wrote in message > Hi , > I was trying to build my project in VC with latest Service Packs but > got this error . > > C:\Program Files\Microsoft Visual > Studio\VC98\ATL\INCLUDE\atlconv.h(125) : error C2440: 'return' : > cannot convert from 'const char *' to 'const unsigned short *' > Types pointed to are unrelated; conversion requires > reinterpret_cast, C-style cast or function-style cast > > I am using some ATL functionality ( String conversion) > In Preprocessor setting I have made UNICODE and _UNICODE , but no > change in error . You have to post some code to get better replies. If it has a lot of non-Standard stuff then try the news:microsoft.vc.* family of newsgroups. Sharad Abhijit Bhadra wrote: > Hi , > I was trying to build my project in VC with latest S... what's this? '->' All, I know that '->' is used in object oriented PHP, but I saw this in the Moodle code (www.moodle.org)$CFG->dbtype = 'mysql'; // mysql or postgres7 (for now) $CFG->dbhost = 'localhost'; // eg localhost or db.isp.com$CFG->dbname = 'moodle'; // database name, eg moodle $CFG->dbuser = 'root'; // your database username$CFG->dbpass = 'mypassword'; // your database password $CFG->prefix = 'mdl_'; // Prefix to use for all table names You can "echo$CFG->dbtype;" and get "mysql" This isn't calling functions from an object, rather seems to be applying properties to a new "object"??? There is no $something = new ClassName, so This is what I figure. Its been a while since I cooded PHP and have never seen this. This seems like a realy good way to apply a number of atttribs to a "variable" without having to create an array -- unless that is a shorthand way of creating an array... Thanks -Wes Yates On 11 Feb 2005 09:15:55 -0800, gmac63@charter.net wrote: >You can "echo$CFG->dbtype;" and get "mysql" > >This isn't calling functions from an object, rather seems to be >applying properties to a new "object"??? There is no $something = new >ClassName, so This is what I figure. If you use a variable as an object PHP automatically creates an object (I believe this... error: expected '=', ',', ';', 'asm' or '__attrib Hi I'm trying to compile an ADC Driver & come acrosss the following error. I've no experience writing drivers before, and hence have no clue how to fix it. Hope someone out there has encountered the problem & suggesst a fix for the same. The Error is I get is : qadc.c: At top level: qadc.c:97: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'qadc_read' make: *** [qadc.o] Error 1 [root@localhost qadc]# ########################################################################### ADC Driver Code ########################################################################### #define MODULE #define __KERNEL__ #include <linux/config.h> #include <linux/module.h> #include <linux/kernel.h> /* printk */ #include <linux/fs.h> / #include <linux/errno.h> /* error codes */ #include <linux/types.h> /* size_t */ #include <linux/proc_fs.h> /* proc file system */ #include <linux/fcntl.h> #include <asm/system.h> /* cli, flags */ #include <asm/uaccess.h> /* copy from/to user */ /*Registers to get qadc access*/ volatile unsigned short * qadcmcr = (unsigned short *)0x40190000; volatile unsigned short * qacr0 = (unsigned short *)0x4019000a; volatile unsigned short * qacr1 = (unsigned short *)0x4019000c; volatile unsigned short * qacr2 = (unsigned short *)0x4019000e; volatile unsigned short * qasr0 = (unsigned short *)0x40190010; volatile unsigned short * qasr1... '[OFF]' as in 'offensive'??? Hi, given that 'off-topicness' is indicated as '[OT]' and taking a look at those postings that started the threads indicated as '[OFF]' (which may both be seen as being somewhat offensive) may lead to the conclusion that '[OFF]' stands for offensiveness. I don't think that this is the intended meaning so what actually *does* '[OFF]' mean? I never came across that abbreviation before (although I have been around on the USENET for quite some time) but maybe it is worth knowing? Josef 'Jupp' Schugt NOTE: mails >100 KiB are ignored -- German edition of comp.lang.ruby FAQ - http://oss.erdfunkstelle.de/ruby/ Aurox Linux - http://qurl.net/7q | http://qurl.net/7r - Firefox Thunderbird - http://qurl.net/7s | http://qurl.net/7t - Liferea Enigmail - http://qurl.net/7u | http://qurl.net/7v - GnuPG [Josef 'Jupp' Schugt <jupp@gmx.de>, 2004-12-10 23.20 CET] > I don't think that this is the intended meaning so what actually *does* > '[OFF]' mean? Off-topic. ... replacement for '{' and '}' ? I am still playing around with what kind of syntax I would like to mark up my documents. Are there equivalent long substitutes for { and } when they are not used to describe arguments to functions? Something like \begin{group} and \end{group}. In other words, if I could force myself to write, say, \begin{group} \it ... \end{group} instead of {\it ... }, then I believe I could identify from the markup context what is an argument that belongs to a just invoked macro and what is text. {Of course, in this context, \textit{...} would be better.} No more ambiguity whether a in \myfunction{a} is an argument or just text. Is there a way to make latex barf when it sees an ordinary '{' in text, rather than \begin{group}, but not barf when I want it (to denote macro arguments)? Regards, /iaw On Aug 16, 6:01=A0pm, "ivo...@gmail.com" <ivo...@gmail.com> wrote: > Is there a way to make latex barf when it sees an ordinary '{' in > text, rather than \begin{group}, but not barf when I want it (to > denote macro arguments)? What do you mean exactly? I don't understand. Do you have in mind your- to-be-new-syntax or just regular latex? Cheers, Tomek ivowel@gmail.com wrote: > I am still playing around with what kind of syntax I would like to > mark up my documents. > > Are there equivalent long substitutes for { and } when they are not > used to describe arguments to functions? Something like \begin{group} > and \end{gr... Are there the functions 'leEdgeSetLayer' and 'leEdgeAddAll' in skill? I found the two functions in one skill scripts, but mayn't find them in documents, even searched out any info with google. Are they exist? If they're old functions, how to find the replaced ones? Thanks for your help! B.R. Joffre On Jun 20, 10:50 pm, "tech11" <tec...@sohu.com> wrote: > I found the two functions in one skill scripts, but mayn't find them in > documents, even searched out any info with google. Are they exist? If > they're old functions, how to find the replaced ones? Thanks for your help! In less time than it took for me to respond to this question, anyone can find out the current status of any of the more than 50,000 SKILL functions with a single click (including exactly which releases your functions of interest exist in, whether they are documented & supported, and if they've been changed or deleted between releases, and if so, what the arguments are and how to recover from the changes or deletions, etc.). 1. Bring up the two-part SKILL Survey (CIW: Tools -> SKILL -> Survey) 2. Point to your IL files to create a comprehensive INVENTORY of all functions called & defined & where located 3. Enter your email address to receive an automated multi-part detailed analysis by return email Information you'd find in that survey result would include, for example, are that leEdgeSetLayer & leEdgeAddAll are both private (undocumented & unsupported) SKILL functions; available in all releas... problem with 'include' and 'file_exists' function i encountered this problem: "include('inc.php')" will work problely but "include('./inc.php') doesn't work .. both file_exists('inc.php') or file_exists('./inc.php') didn't return the right value.this always show "file doesn't exists' my environment is win2003+iis+php5 how to fix it ? sorry to my English thanks to you. :) > "include('inc.php')" will work problely >but "include('./inc.php') doesn't work .. There are plenty of situations where this will happen. If a file name begins with ./, it will be looked up with include_path relative only to the current working directory, not the current script. Are you SURE you know what the current working directory is when the script is started? >both file_exists('inc.php') or file_exists('./inc.php') didn't return >the right value.this always show "file doesn't exists' include() uses include_path to search for files. file_exists() doesn't. >my environment is win2003+iis+php5 > >how to fix it ? The fix may be to correct the "right" value. Don't think that! "Gordon Burditt =D0=B4=B5=C0=A3=BA " thanks for your answer. > > There are plenty of situations where this will happen. If a file > name begins with ./, it will be looked up with include_path relative > only to the current working directory, not the current script. >... Re: '^=' and '~='? Duckhye, According to the doc ( http://xrl.us/befwjx ) they, and one other set of characters, and the mnemonic 'NE' all represent 'NOT EQUAL'. Art ------- On Wed, 11 Feb 2009 16:52:40 -0600, Duck-Hye Yang <dyang@CHAPINHALL.ORG> wrote: >Hello, >What is the difference between '^=' and '~='? > >Thanks, >Duckhye ... Look! Up in the sky! It's a bird! It's a plane! No-- it's WONDER Yes, Wonder Chimpie-- strange primate from another planet!! Knows everything about IT (with the exception of a proxy server and how to kill file). All bow down when he comes around! Thank you, Wonder Chimpie, for saving us from ourselves! ~~~~~~~~~~~~~~~~~~~~~ This message was posted via one or more anonymous remailing services. The original sender is unknown. Any address shown in the From header is unverified. ... New Daily Quiz... OK, Not Really... I am looking for an optimized not-'in-place' 'quick select' algorthm/matlab script/c code Hello All, The 'quick select' algorithm finds the kth smallest element in the array wi= thout doing a sort first (https://en.wikipedia.org/wiki/Quickselect ). With= proper selection of the k value(s) it is one of the fastest algorithms to = find the median. I have spent considerable time trying to find a not-'in-place' 'quick selec= t' algorithm. I have written my own version in MATLAB, but I am certain the= re is an implementation 'out there' that is more optimized than what I have= done (hopefully in C). I found a reference to the not-'in-place' version being significantly faste= r than the 'in-place' version, which makes sense because it eliminates a lo= t of data swapping within the array at a cost of additional memory that is = 1X or 2X the size of the input array. Since I want to apply it to a fairly = short array, having one or two additional arrays of the same length is not = significant in terms of memory. Does anyone know where to find an optimized not-'in-place' version of 'quic= k select'? Thanks, Dirk Bell ... Bug in Norcroft C compiler's treatment of empty 'if' blocks I have just stumbled across an insidious bug in the Norcroft C compiler (Norcroft RISC OS ARM C vsn 5.54 [04 Apr 2003]). Given an empty conditional code block, or one with no effect, (e.g. a vestige of a debugging macro), subsequent instructions may wrongly be executed conditionally. The following test case illustrates this: typedef struct { int a; int b; } struct1; void func2(int *foo) { (*foo)++; } int func1(struct1 *comp, int params) { int status = 0; int flush; flush = (params == 1); if (flush) { } do { switch (status) { case 0: func2(&comp->b); break; case 1: func2(&comp->b); break; } } while (status == 0); return status; } CC ADFS::Rissa.$.Programming.AcornC/C++.User.c.NorBug -IC: -c -S -desktop ^ -o ADFS::Rissa.$.!BOOT.Resources.!Scrap.ScrapDirs.IDdisable d.x28962a4a EXPORT func2 func2 LDR a2,[a1,#0] ADD a2,a2,#1 STR a2,[a1,#0] MOV pc,lr DCB &66,&75,&6e,&63 DCB &31,&00,&00,&00 DCD &ff000008 IMPORT __rt_stkovf_split_small EXPORT func1 func1 MOV ip,sp STMDB sp!,{a1,a2,fp,ip,lr,pc} SUB fp,ip,#4 CMP sp,sl BLMI __rt_stkovf_split_small MOV a3,#0 CMP a2,#1 MOVNE a2,#0 MOVEQ a2,#1 CMP a2,#0 ... Reprise: 'in out' parameters for functions I just ran across a need for an 'in out' parameter in a function, in "real code", so I thought I post it here "just for fun" :). This is what I wanted to declare: function Parse (Error_Label : in String; Token : in out Token_List.List_Iterator) return String; -- Process Token, which should contain '([Config_File =>] <string>)'. -- Return the string. -- Delete parsed tokens from Token. Token must be 'in out', because the next parse function called wants to work on the stuff after the config file. Parse must be a function, because I'm returning a String. The work-around is to use a procedure and a bounded string: procedure Parse (Error_Label : in String; Token : in out Token_List.List_Iterator; Config_File_Name : out OpenToken.Buffers.Bounded_String); In this instance, the body of Parse deals with OpenToken.Buffers.Bounded_String anyway, so there's no actual new overhead introduced. But the user interface is not as clean as it could be. -- -- Stephe Stephen Leake <stephen_leake@acm.org> wrote: : Token : in out Token_List.List_Iterator) Is Token : access Token_List.List_Iterator) not an option? "Georg Bauhaus" <sb463ba@l1-hrz.uni-duisburg.de> wrote in message news:c546fd$lkb$3@a1-hrz.uni-duisburg.de... > Stephen Leake <stephen_leake@acm.org> wrote: > > : Token : in out Token... error C2664: 'strcpy' : cannot convert parameter 2 from 'char' to 'const char *' Hi, i wrote the code in C and compiled in VC++ compiler. at that time it has thrown the below mentioned error. error C2664: 'strcpy' : cannot convert parameter 2 from 'char' to 'const char *' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast Herewith i have added the code also. ----------------------------------- #include "stdafx.h" int _tmain(int argc, _TCHAR* argv[]) { char message[15]=":80a1:SSBKRO"; char *location; char* receiver='\0'; char* rec='\0'; int i,j,cnt=0; int mt511=(int) strlen(":80a1:"); printf("%s\n",message); if((location=strstr(message,":80a1:")) != NULL) { for(i=0;i<mt511;i++) location++; for(j=mt511;j<mt511+8;j++) while(*location!='\0') { strcpy(rec,message[j]); strcat(receiver,rec); cnt++; } /*for(i=0;i<mt511;i++) location++; strncpy(receiver,location,cnt);*/ } else { for(i=mt511;i<cnt;i++) { strcpy(rec,"X"); strcat(receiver,rec); } } printf("%s\n",receiver); return 0; } ---------------------------------------- Kindly help me to resolve this issue. Thanks In advance. Regards, kaizen kaizen wrote: > { strcpy(rec,message[j]); second parameter is a character, and should be a C-string (const char*) perhaps you wanted to do like: char tmp[2]; tmp[0]=message[j]; tmp[1]='\0'... Matching a View's columns to it's underlying table's columns Hello, Using SQL Server 2000, I'm trying to put together a query that will tell me the following information about a view: The View Name The names of the View's columns The names of the source tables used in the view The names of the columns that are used from the source tables Borrowing code from the VIEW_COLUMN_USAGE view, I've got the code below, which gives me the View Name, Source Table Name, and Source Column Name. And I can easily enough get the View columns from the syscolumns table. The problem is that I haven't figured out how to link a source column name to a view column name. Any help would be appreciated. Gary select v_obj.name as ViewName, t_obj.name as SourceTable, t_col.name as SourceColumn from sysobjects t_obj, sysobjects v_obj, sysdepends dep, syscolumns t_col where v_obj.xtype = 'V' and dep.id = v_obj.id and dep.depid = t_obj.id and t_obj.id = t_col.id and dep.depnumber = t_col.colid order by v_obj.name, t_obj.name, t_col.name garyderousse@yahoo.com (Gary DeRousse) wrote in message news:<9ce1cc62.0311051041.2dd0f428@posting.google.com>... > Hello, > > Using SQL Server 2000, I'm trying to put together a query that will > tell me the following information about a view: > The View Name > The names of the View's columns > The names of the source tables used in the view > The names of the columns that are used from the source tables >... Like '' & '' & '' Having this description column in a table "Cookies, peanut butter sandwich, regular" When using this WHERE clause: WHERE (((Food_Data.Description) Like "*Butter*" & "*Peanut*")); I dont get any results, however when using it this way round WHERE (((Food_Data.Description) Like "*Peanut*" & "*Butter*")); I get the row as expected. I assume that the query looks for them in order. Is there a way i can get around this and make the query search for both keywords no matter which order i ype them in. Thanks Dave [posted and mailed] SkunkDave (dave_casserly@totalise.co.uk) writes: > Having this description column in a table > > "Cookies, peanut butter sandwich, regular" > > > When using this WHERE clause: > > WHERE (((Food_Data.Description) Like "*Butter*" & "*Peanut*")); > > I dont get any results, however when using it this way round > > WHERE (((Food_Data.Description) Like "*Peanut*" & "*Butter*")); > > I get the row as expected. > > I assume that the query looks for them in order. The query looks for a string that matches the pattern "*Peanut**Butter*", so obviously it's not going to match "Butter Peanut". As suggested by Harald Albrech this works: WHERE (Food_Data.Description Like "*Butter*" or Food_Data..Description Like "*Peanut... Return value of 'each', 'current', 'next', 'end' These array functions: 'each', 'current', 'next', 'end' They return a reference or a value. let's say I want to modify the last value of an array without iterating through all of them. I would do: <? end($array) ; current($array)="new value" ; ?> is that posible?? Thanks. Hermann.Richter@gmail.com wrote: > These array functions: 'each', 'current', 'next', 'end' > > They return a reference or a value. They return values. > let's say I want to modify the last value of an array without iterating > through all of them. > > I would do: > > <? > end($array) ; > current($array)="new value" ; > ?> > > is that posible?? Try end($array); $array[key($array)] = "new value"; Chung Leong wrote: > Hermann.Richter@gmail.com wrote: > > These array functions: 'each', 'current', 'next', 'end' > > > > They return a reference or a value. > > They return values. > > > let's say I want to modify the last value of an array without iterating > > through all of them. > > > > I would do: > > > > <? > > end($array) ; > > current($array)="new value" ; > > ?> > > > > is that posible?? > > Try > > end($array); >$array[key($array)] = "new value";$array[(sizeof(\$array...

Where's the 'forth algebra' ?
For beginners who don't want to learn by doing [like bicycling] eg. for the BEGIN code1 WHILE code2 REPEAT construct:-- code1 is executed N times, wheras code2 is executed N-1 times. The stak-growth during the N*code1 + (N-1)*code2 executions must be constant, independant of N. For N,x,y,C : intergers:- Nx+(N-1)y = C => x = y = 0 is a solution. And since WHILE consumes tos, code2 must increment the stack to compensate for the consumption by WHILE. Also code1 must exit with at least 1 for stakDepth. And what else did I forget ? So where's the forth algebra, listing the tos-conditions at the various reserved words in the various control structures ? == TIA On Jan 1, 8:38=A0pm, AliBama@gmail wrote: > For beginners who don't want to learn by doing [like bicycling] > =A0eg. for the BEGIN code1 WHILE code2 REPEAT construct:-- > code1 is executed N times, wheras code2 is executed N-1 times. > The stak-growth during the N*code1 + (N-1)*code2 executions > must be constant, independant of N. > For N,x,y,C : intergers:- > Nx+(N-1)y =3D C > =3D> x =3D y =3D 0 is a solution. > And since WHILE consumes tos, code2 must increment the stack > to compensate for the consumption by WHILE. > Also code1 must exit with at least 1 for stakDepth. > And what else did I forget ? > So where's the forth algebra, listing the tos-conditions at the > various reserved words in the various control structures ? Why are you making this comple...

Web resources about - Modify tunable global parameters in 'C' S-Function - comp.soft-sys.matlab

Resources last updated: 3/30/2016 12:36:30 PM