COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Ezplot constants?

• Email
• Follow

```I want to plot some quadratic functions with varying coefficients, for example:

syms x
syms y
ezplot('2*x^2 + 3*y^2 = 1')

but I want to iterate/vary the '2' and '3' in that expression, something like
a = 2
b = 3
ezplot('a*x^2 + b*y^2 = 1')

but of course a and b aren't recognized inside the ' ' .

How should I do this?

Thanks,

Dave
```
 0
Reply daviddoria (340) 10/17/2009 3:47:03 PM

See related articles to this posting

```"David Doria" <daviddoria@gmail.com> wrote in message
news:hbcotn\$e16\$1@fred.mathworks.com...
>I want to plot some quadratic functions with varying coefficients, for
>example:
>
> syms x
> syms y
> ezplot('2*x^2 + 3*y^2 = 1')
>
> but I want to iterate/vary the '2' and '3' in that expression, something
> like
> a = 2
> b = 3
> ezplot('a*x^2 + b*y^2 = 1')
>
> but of course a and b aren't recognized inside the ' ' .
>
> How should I do this?
>
> Thanks,
>
> Dave

a = 10
b = 11
ezplot(subs('a*x^2 + b*y^2 = 1'))

--Nasser

```
 0

```"Nasser M. Abbasi" <nma@12000.org> wrote in message
>
> "David Doria" <daviddoria@gmail.com> wrote in message
> news:hbcotn\$e16\$1@fred.mathworks.com...
>>I want to plot some quadratic functions with varying coefficients, for
>>example:
>>
>> syms x
>> syms y
>> ezplot('2*x^2 + 3*y^2 = 1')
>>
>> but I want to iterate/vary the '2' and '3' in that expression, something
>> like
>> a = 2
>> b = 3
>> ezplot('a*x^2 + b*y^2 = 1')
>>
>> but of course a and b aren't recognized inside the ' ' .
>>
>> How should I do this?
>>
>> Thanks,
>>
>> Dave
>
> a = 10
> b = 11
> ezplot(subs('a*x^2 + b*y^2 = 1'))

Another alternative:

a = 10;
b = 11;
ezplot(a*x^2+b*y^2-1)

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

```
 0
Reply slord (13686) 10/17/2009 7:09:07 PM

```> > a = 10
> > b = 11
> > ezplot(subs('a*x^2 + b*y^2 = 1'))
>
> Another alternative:
>
> a = 10;
> b = 11;
> ezplot(a*x^2+b*y^2-1)
>
> --
> Steve Lord

Great - thanks all!
```
 0
Reply daviddoria (340) 10/19/2009 12:54:02 PM

3 Replies
74 Views

Similar Articles

11/30/2013 8:21:01 AM
page loaded in 50116 ms. (0)

Similar Artilces:

Initialization of constants
in the declaration is the member has an const > integral type? I guess you wanted to type: "if the member has a const integral type". Well, I guess it may have two reasons: 1.) To be able to create arrays of that (named) size 2.) To avoid using the preprocessor for integral constants WW aka Attila [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]

Initialize constants
I have a Constants class and a Variable class. I need to initialize a constant in the Constants class: public static final String FILE_NAME; The Variable class has a public String method that returns the full pathway for the file name. public String getVariable( String variableName ) throws Exception; I have a getPath() method in Constants that calls getVariable in Variable: private static String getPath( String variableName ) throws Exception { try { Variable v = new Variable(); return v.getVariable( variableName ); } catch ( Exception e ) { throw e; } } Now... expected instead. How do I go about initializing the value of FILE_NAME? I *must* use Variable::getVariable(). Thanks for your help. "John Smith" <wleung7@gmail.com> wrote in message news:1152825768.284557.43280@35g2000cwc.googlegroups.com... >I have a Constants class and a Variable class. > > I need to initialize a constant in the Constants class: > public static final String FILE_NAME; > > The Variable class has a public String method that returns the full > pathway for the file name. > public String getVariable( String variableName ) throws Exception

modification of constants
A perennial trap for the unwary and the inexperienced is modification of literals: for example (defun foo (x) (let ((y (list #(1) #(2)))) (format t "~S" y) (setf (aref (second y) 0) x) (format t "~S" y))) similar to a query here a little while ago. It's relatively easy to understand that this attempts to modify the literal objects in the program, and (in the CLHS under QUOTE) this is forbidden. So far, so usual: this issue comes up moderately regularly here. But what about slightly more subtle cases? (let ((location (cons nil nil))) (

Empty constants
I've just created a static class that contains a number of static, final, read-only, empty constants for common classes. For example, I've got: public static final Map MAP = new EmptyMap(); where EmptyMap is a map implementation that has zero elements and throws an UnsupportedOperationException if you try to modify it. The general idea is that I'm tired of constantly checking to see if my methods return null before I try to use to some object that they return, like a Map or List or the like. Easier just to return an empty, dummy object. Question: surely somebody, somewhere must be doing this already. Is there a standard class out there that everybody uses for this purpose? Maybe something in Apache Commons? Spud wrote: > I've just created a static class that contains a number of static, > final, read-only, empty constants for common classes. For example, I've > got: > > public static final Map MAP = new EmptyMap(); > > where EmptyMap is a map implementation that has zero elements and throws > an UnsupportedOperationException if you try to modify it. > [...] > Question: surely somebody, somewhere must be doing

Global Constants
Hi, I have some constants in my VHDL design, which I want to access from different modules. Can I make the constants global? Or do I have to redefine them in multiple modules? Thanks. You can make them global by defining them in a package 'mypackage' and then compile the package which will default be compiled into the work library use work.mypackage.all; will make the constants visible. Sorry that didn't come out very well, What I mean ot say was once you have compiled your package it will by default be compiled into the 'work' library.In all of your modules that you wish to make the constants visible usa a use work.mypackage.all; and then all the package contents,including any constants, will be visible in that module. ed wrote: > I have some constants in my VHDL design, which I want to access from > different modules. Can I make the constants global? Or do I have to > redefine them in multiple modules? Jezworld has suggested to declare the constants in a package. An other option is to use generic parameters. entity myentity is generic( mygenericparam : integer:=1 ); port( in : std_ulogic; out : std_ulogic ); When instantiating

Maths constants
What is the best way to define mathematical constants for use in Fortran? For example I could define module Constants real(8), parameter :: E = 2.718281828459045d0 ! e real(8), parameter :: PI = 3.141592653589793d0 ! pi end module Constants but there are other possibilities. Is there a recommended standard/best practice? Is there a 'constants' module in the 2008 spec? Thanks, Simon On 18 jan, 14:46, Simon Geard <si...@whiteowl.co.uk> wrote: > What is the best way to define mathematical constants for use in > Fortran? For example I could define > > module Constants > =A0 real(8), parameter :: E =3D 2.718281828459045d0 =A0! e > =A0 real(8), parameter :: PI =3D 3.141592653589793d0 ! pi > end module Constants > > but there are other possibilities. Is there a recommended standard/best > practice? Is there a 'constants' module in the 2008 spec? > > Thanks, > > Simon I'd say that the above is the most reliable way to define them. You could use transcendental functions like exp() and atan() to get mathematically sane expressions for at least these two constants, but you

constants not constant?
> > >>constant who's value is known at compile time, then do this: >> >>#define N 10 > > > Wasn't the point of having "const" (in part) to be able to replace > #define? > AFAIK, that applies only in C++. In C, you still have to use #define for true compile time constants. -- Daniel Rudy Email address has been encoded to reduce spam. Remove all numbers, then remove invalid, email, no, and spam to reply. On Tue, 10 May 2005 19:17:30 -0700, E. Robert Tisdale wrote: > geneing@gmail.com wrote: > >> How come

named constants vs. literal constants
value passed from the calling routine.) As to whether using 1*BLABLA/3, 1./3.*BLABLA or ONE/THREE*BLABLA is better, am I correct in concluding that if the quantity is precisely representable in hardware (e.g. double-precision versions of small integer constants), then there is no reason to use named constants, except of course if I have something like 4543543./7878979. several times, in which case a name would make the code more readable? This regards expressions. If that is true, then I have to ask Richard why he has stuff like real_zero. Of course, for an assignment, if I have..., it is deemed necessary. Did everyone expect this? This means that named constants ARE a good idea, since then I can write ONE/THREE*BLABLA; 1./3.*BLABLA loses my precision (hums R.E.M.'s "Losing my Religion"). The other alternatives are 1.*BLABLA/3., which I don't like, and 1.0D0/3.*BLABLA (it's enough to promote one of them), which I don't like. Phillip Helbig---remove CLOTHES to reply wrote: > if one considers 1./3.*ONE to be the analog of 1/3*ONE, in other words > things are evaluated in the order specified by the standard and the > conversion

Use of OLE constants in PHP
Hello, I try to create a Word document from PHP. I use the COM class to create the Word object and the methods and properties of the object ot access it. No problem until I use the predefined constants of Word as parameter of methods or value of properties : I get an exception in PHP. Here is my code : com_load_typelib("Word.Application"); \$word = new COM("Word.Application"); \$doc = \$word->Documents->Add(); \$doc->Activate(); \$doc->Select(); \$word->ActiveDocument->PageSetup->Orientation = wdOrientLandscape; \$word->Selection->TypeText("..., > > I try to create a Word document from PHP. > > I use the COM class to create the Word object and the methods and > properties of the object ot access it. > > No problem until I use the predefined constants of Word as parameter of > methods or value of properties : I get an exception in PHP. > > Here is my code : > > com_load_typelib("Word.Application"); > \$word = new COM("Word.Application"); > \$doc = \$word->Documents->Add(); > \$doc->Activate(); > \$doc->Select(); > \$word->ActiveDocument->

Php constants in php.ini
I am trying to set user_agent = PHP_VERSION in php.ini. In my php.ini the instructions say that you can use constants in the php.ini file. The only constants I can get to work, though, are the error level constants like E_ALL, E_ERROR, E_WARNING, etc., ... Is anyone aware of some sort of trick to getting others to work? (I was thinking it would be nice to have the user agent string used by my Php scripts to use PHP_VERSION in the string.) -- ***************************** Chuck Anderson • Boulder, CO http://www.CycleTourist.com Integrity is obvious. The lack of it is common. *****************************

Compile time pointer constants
Let, at namespace scope, extern char const a[] = "Woof"; extern char const* const p = "Moo"; and given a template like template< char const* s > void foo() {} which, if any, of the following are valid? foo<a>(); foo<p>(); foo<p+0>(); PS: this is not a homework assignment. ;-) Cheers, - Alf -- A: Because it messes up the order in which people normally read text. Q: Why is it such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet and in e-mail? [ See http://www.gotw.ca/resources/clcm.htm

module with commonly used constants?
Someone once told me that there is either a perl module with commonly used constants or a method of using commonly used constants. I am building a module which requires constants for determining if a value is an integer, and email address, a url, etc. Is there a module out there that already contains a large number of commonly used constants? "none" <dtiberio5@hotmail.com> wrote: > Someone once told me that there is either a perl module with commonly > used constants or a method of using commonly used constants. > > I am building a module which requires constants for determining if a > value is an integer, and email address, a url, etc. Is there a module > out there that already contains a large number of commonly used > constants? I guess you mean: http://search.cpan.org/search?query=regex%3A%3Acommon&mode=all A constant is something like 2 You probably mean a regexp to check if something is an integer, etc. -- John Small Perl scripts: http://johnbokma.com/perl/ Perl programmer available: http://castleamber.com/ I ploink googlegroups.com :-)

How are constants stored ?
Hello all, I always wondered the following: How are constants implemented in an FPGA ? How many can be stored without causing bottlenecks (routing issues)? A quick scan of a Spartan3 indicated there is no ROM. Thx -Roger Roger Bourne wrote: > How are constants implemented in an FPGA ? All FPGA gates are synthesized in look-up tables. A constant is synthesized with tables set for fixed output. Think of it as wires to power or ground. > How many can be stored > without causing bottlenecks (routing issues)? Try it and see. One constant bit per LUT is maximum. -- Mike Treseler Mike Treseler wrote: > Roger Bourne wrote: > >> How are constants implemented in an FPGA ? > > > All FPGA gates are synthesized in look-up tables. > A constant is synthesized with tables set for fixed output. > Think of it as wires to power or ground. > >> How many can be stored >> without causing bottlenecks (routing issues)? > > > Try it and see. > One constant bit per LUT is maximum. > > -- Mike Treseler and some routing resources have tie offs (to gnd or vcc) mostly on the gaskets of hard ip blocks. Aurash

wxPython ICON constants
I've been wondering, is there a way to grab icon information just given the type of OS? So if I wanted to grab the Firefox icon, how would I do that since the user could have changed the default icon to something else? Is there a library of these constants?

; 2 > Statement at (2) invalid in context established by statement at (1) > > As I read it, the program is having a problem with the 'open' statement. > But I am very new to FORTAN and really have no idea. Any guidance > would be appreciated. > > Mike -- Paul van Delst CIMSS @ NOAA/NCEP/EMC Mike: As Paul pointed out F77 parameters are really constants. You might declare the parameters as namelist variables, initialize them to default vlues using replacement statements, and use Namelist input to change these default values. Skip On Thu... IN ADVANCE* (i.e. to be either PARAMETERs or literal constants) Thus, in F77, you cannot size an array that way (there are some extensions which will allow it, but not using that particular syntax anyway). I'm not sure how your system is exactly set up. You have several options: 1) Use a F90 compiler, add allocatable attribute to the arrays and ALLOCATE them. There are free fortran compilers at www.g95.org and gcc.gnu.org (gfortran). 2) The "old" (F77) way was to declare the arrays to be of "maximal possible" size, and use only a smaller part of it. Thus

Where to put the constants?
Some of the science and engineering programs posted in this newsgroup have started out with long sections composed of constants. There are a number of preliminary computations carried out either with initialization expressions or early in the program. I don't remember programs being written this way in the olden days. Instead I remember that constants were pre-computed, as much as possible, before wirting a program. I'm not a specialist in astrophysics or internal combustion engines, so when I see such a pre-amble, it often distracts me from the rest of the program. Likewise, I find long lists of declarations distracting as well. How do "real" scientists handle this? Yes, the short answer might be "put it in a module." [smile] -- e On Apr 24, 2:39 pm, e p chandler <e...@juno.com> wrote: > Some of the science and engineering programs posted in this newsgroup > have started out with long sections composed of constants. There are a > number of preliminary computations carried out either with > initialization expressions or early in the program. I don't remember > programs being written this way in the olden days. Instead I

No math constants in the C++ standard?
Hi all. Every now and then I see people who complain that "The C++ standardizing committee screwed up when they exluded the constant M_PI from the C++ standard." I can imagine a number of arguments why M_PI never made it to the standard, like - Macros are not good programming practice. - Constants like pi and the natural logarithm e are well-defined irrespective of C++, anyone can look up a math table and insert their own constants. - C++ have other ways of defining constants than C, so there are no need to drag C programming practices along. But all... > never made it to the standard, like > > - Macros are not good programming practice. > - Constants like pi and the natural logarithm e > are well-defined irrespective of C++, anyone > can look up a math table and insert their own > constants. > - C++ have other ways of defining constants > than C, so there are no need to drag C > programming practices along. > > But all of that is only speculation. > > So: Why was M_PI (or some similar constant) excluded > from the standard? As I understand, it was excluded from > the C standard

Init structure of constants
Hi Group, I am trying to define a strucutre of constants. Then switch on this structure of constant values. In the following example of my problem the code fails to compile due to: case (constants.one): In this statement, "constants.one" is not constant, but occurs in a context that requires a constant expressio n. How should I define a structure of const to switch on. Thanks Stuart #include <stdio> #include <stdlib> struct Constant { const int one; const int two; } constants ={ 65, 66 } ; int main (int argc, char **argv) { char buffer = 'A'; switch (buffer) { case (constants.one): break; case (constants.two): break; } return 0; } stuie_norris@yahoo.com.au wrote: > Hi Group, > > I am trying to define a strucutre of constants. Then switch on this > structure of constant values. > > In the following example of my problem the code fails to compile due > to: > > case (constants.one): > In this statement, "constants.one" is not constant, but occurs in a > context that requires a constant expressio > n. > > How should I define a structure

How to declare global constants?
I would like to declare a constant in a module (.pm), so other perl scripts can use the module and the constant it contains. I tried use constant BASEDIR => 'path_name'; in the module. But when I use this module, perl complains that BASEDIR is a bareword. How do you make this work? Really appreciate your comment. In article <zyeZh.8362\$Dq6.6529@edtnps82>, Louis <t051315@hotmail.com> wrote: > I would like to declare a constant in a module (.pm), so other perl > scripts can use the module and the constant it contains. > > I tried > use constant BASE

Macros vs. Global Constants
Hi, I would like to ask the advantages and disadvantages of using global constants vs. macros. Something like: const int kMyErrorCode = 100; vs. #define MYERRORCODE 100 and then use it in several functions in some way like: myfunc() { use(kMyErrorCode); // vs. use(MYERRORCODE); } At which point each of the values are instantiated? What do you prefer to do? What advantages you see in using global constants? Are there any differences if the constant is an object? Something like: const std::string kErrorMsg = "This is my error message"; vs. #define ERRORMSG std::string("This is my error message" Thanks in advance, -- Isaac Rodriguez SW Enginieer - Autodesk ---------------------------------------- There are 10 types of people. Those who understand binary, and those who don't. [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] In article <1089988559.98135@hqnntp01.autodesk.com>, Isaac Rodriguez <isaac.rodriguez@autodesk.com> writes >I would like to ask the advantages and disadvantages of using global >constants vs. macros. Something