f

#### Fortran equivalent to Matlab's eig() function

I'm trying to convert some Matlab code into Fortran 77, as Matlab
takes days to solve the multiple finite difference systems I need to
solve for.  All the Matlab code transfers relatively easily into F77,
except for the main solution function (which Matlab makes super
easy).  I'm not sure if there's some ready-made code I can cut and
paste into the F77 program, but essentially I'm trying to substitute
for the following line:

[V,D]=eig(A,B,'qz')

Where

Does anyone have any suggestions or advice for how I can implement
that in F77?

Dave

 0
9/8/2008 3:12:26 PM
comp.lang.fortran 11941 articles. 2 followers.

15 Replies
1640 Views

Similar Articles

[PageSpeed] 40

On Mon, 08 Sep 2008 08:12:26 -0700, Dave wrote:

> program, but essentially I'm trying to substitute for the following
> line:
>
> [V,D]=eig(A,B,'qz')
>
> Where
>
> Does anyone have any suggestions or advice for how I can implement that
> in F77?
>

Possibly http://www.netlib.org/lapack/double/dhgeqz.f is what you need.

> Dave

Jörgen

 0
j.tegner (9)
9/8/2008 4:03:31 PM
Fantastic.  That looks exactly like what I need.

Thanks!
Dave

On Sep 8, 11:03 am, J=F6rgen Tegn=E9r <j.teg...@telia.com> wrote:
> On Mon, 08 Sep 2008 08:12:26 -0700, Dave wrote:
> > program, but essentially I'm trying to substitute for the following
> > line:
>
> > [V,D]=3Deig(A,B,'qz')
>
> > Where
>
> > Does anyone have any suggestions or advice for how I can implement that
> > in F77?
>
> Possiblyhttp://www.netlib.org/lapack/double/dhgeqz.fis what you need.
>
> > Dave
>
> J=F6rgen


 0
9/8/2008 4:15:41 PM
J=C3=B6rgen Tegn=C3=A9r wrote:
> On Mon, 08 Sep 2008 08:12:26 -0700, Dave wrote:
>=20
>=20
>>program, but essentially I'm trying to substitute for the following
>>line:
>>
>>[V,D]=3Deig(A,B,'qz')
>>
>>Where
>>
>>Does anyone have any suggestions or advice for how I can implement that=

>>in F77?
>>
>=20
>=20
> Possibly http://www.netlib.org/lapack/double/dhgeqz.f is what you need.=

Good heavens, what a (stylistic) mess...idea for a new TV show:  Fortran =

Makeover, Bedrock Edition

>=20
>=20
>>Dave
>=20
>=20
> J=C3=B6rgen

--=20

Gary Scott
mailto:garylscott@sbcglobal dot net

Fortran Library:  http://www.fortranlib.com

Support the Original G95 Project:  http://www.g95.org
-OR-
Support the GNU GFortran Project:  http://gcc.gnu.org/fortran/index.html

If you want to do the impossible, don't hire an expert because he knows=20
it can't be done.

-- Henry Ford

 0
garylscott (1355)
9/9/2008 1:21:31 AM
On Mon, 08 Sep 2008 20:21:31 -0500, Gary Scott posted:

> J�rgen Tegn�r wrote:
>> On Mon, 08 Sep 2008 08:12:26 -0700, Dave wrote:
>>
>>
>>>program, but essentially I'm trying to substitute for the following
>>>line:
>>>
>>>[V,D]=eig(A,B,'qz')
>>>
>>>Where
>>>
>>>Does anyone have any suggestions or advice for how I can implement that
>>>in F77?
>>>
>>
>>
>> Possibly http://www.netlib.org/lapack/double/dhgeqz.f is what you need.
>
> Good heavens, what a (stylistic) mess...idea for a new TV show:  Fortran
> Makeover, Bedrock Edition

I never have 2 matrices lying around, where both are almost triangular for
different reasons.

*
*  Purpose
*  =======
*
*  DHGEQZ computes the eigenvalues of a real matrix pair (H,T),
*  where H is an upper Hessenberg matrix and T is upper triangular,
*  using the double-shift QZ method.
*  Matrix pairs of this type are produced by the reduction to
*  generalized upper Hessenberg form of a real matrix pair (A,B):
*
*     A = Q1*H*Z1**T,  B = Q1*T*Z1**T,
*
*  as computed by DGGHRD.

I doubt that matlab has a function designed for Karl Hessenberg's stuff.
Not knowing better, it looks like it might mean something for
representations.
--
We are here and it is now. Further than that, all human knowledge is
moonshine. 3
H. L. Mencken

 0
ron7715 (217)
9/9/2008 4:02:58 AM
If your matrix is sparse (as from finite differences it usually is),
you should use a sparse eigenvalue problem solver, such as e.g.
ARPACK:

http://www.caam.rice.edu/software/ARPACK/

Moreover, sparse matrices are nowadays also very large, so using dense
LAPACK in this case can lead to not so large improvements of the
solution time in comparison with MATLAB.

On 8 Z=E1=F8, 17:12, Dave <dave.har...@gmail.com> wrote:
> I'm trying to convert some Matlab code into Fortran 77, as Matlab
> takes days to solve the multiple finite difference systems I need to
> solve for.  All the Matlab code transfers relatively easily into F77,
> except for the main solution function (which Matlab makes super
> easy).  I'm not sure if there's some ready-made code I can cut and
> paste into the F77 program, but essentially I'm trying to substitute
> for the following line:
>
> [V,D]=3Deig(A,B,'qz')
>
> Where
>
> Does anyone have any suggestions or advice for how I can implement
> that in F77?
>
> Dave


 0
9/9/2008 10:12:19 AM
On 2008-09-09 01:02:58 -0300, Ron Ford <ron@example.invalid> said:

<snip>

> I never have 2 matrices lying around, where both are almost triangular for
> different reasons.
>
> *
> *  Purpose
> *  =======
> *
> *  DHGEQZ computes the eigenvalues of a real matrix pair (H,T),
> *  where H is an upper Hessenberg matrix and T is upper triangular,
> *  using the double-shift QZ method.
> *  Matrix pairs of this type are produced by the reduction to
> *  generalized upper Hessenberg form of a real matrix pair (A,B):
> *
> *     A = Q1*H*Z1**T,  B = Q1*T*Z1**T,
> *
> *  as computed by DGGHRD.
>
> I doubt that matlab has a function designed for Karl Hessenberg's stuff.
> Not knowing better, it looks like it might mean something for
> representations.

The usual style is that there will be some initial processing to bring
the general matrices to a form where the particular problem can be solved.
To find the required initial processing you will have to read more of the
documentation. In this case that means the SECOND sentence of the comment
block quoted above. So although DHGEQZ may not solve your problem directly
the pair of DGCHRD and DHGEQZ would seem to do the job. There are typically
many sensible reasons for breaking the larger problem into smaller parts.
Often there may be several schemes for doing the initial processing. Or
there may be easy methods for updating the initial processing that do not
also apply to the full problem. This is really a numerical analysis issue
rather than a Fortran question.

Sight unseen I would be willing to take a small bet that MatLab is likely
taking more trouble if even possible.


 0
g.sande (1185)
9/9/2008 12:58:19 PM
On Tue, 09 Sep 2008 12:58:19 GMT, Gordon Sande posted:

> On 2008-09-09 01:02:58 -0300, Ron Ford <ron@example.invalid> said:
>
> <snip>
>
>> I never have 2 matrices lying around, where both are almost triangular for
>> different reasons.
>>
>> *
>> *  Purpose
>> *  =======
>> *
>> *  DHGEQZ computes the eigenvalues of a real matrix pair (H,T),
>> *  where H is an upper Hessenberg matrix and T is upper triangular,
>> *  using the double-shift QZ method.
>> *  Matrix pairs of this type are produced by the reduction to
>> *  generalized upper Hessenberg form of a real matrix pair (A,B):
>> *
>> *     A = Q1*H*Z1**T,  B = Q1*T*Z1**T,
>> *
>> *  as computed by DGGHRD.
>>
>> I doubt that matlab has a function designed for Karl Hessenberg's stuff.
>> Not knowing better, it looks like it might mean something for
>> representations.
>
> The usual style is that there will be some initial processing to bring
> the general matrices to a form where the particular problem can be solved.
> To find the required initial processing you will have to read more of the
> documentation. In this case that means the SECOND sentence of the comment
> block quoted above. So although DHGEQZ may not solve your problem directly
> the pair of DGCHRD and DHGEQZ would seem to do the job. There are typically
> many sensible reasons for breaking the larger problem into smaller parts.
> Often there may be several schemes for doing the initial processing. Or
> there may be easy methods for updating the initial processing that do not
> also apply to the full problem. This is really a numerical analysis issue
> rather than a Fortran question.

I'm missing the meaning of pulling eigenvalues on a *pair* of matrices.
When we pulled them on a square matrix in physics, we were finding
principal axes. So the linear algebra had a physical interpretation.

>
> Sight unseen I would be willing to take a small bet that MatLab is likely
> taking more trouble if even possible.

Matlab being an educational tool and Hessenberg form being beyond the
content for a semester of linear algebra, I would put up two dollars of
risk capital to contend to the contrary.
--
Wealth - any income that is at least one hundred dollars more a year than
the income of one's wife's sister's husband. 6
H. L. Mencken

 0
ron7715 (217)
9/9/2008 7:16:39 PM
On 2008-09-09 16:16:39 -0300, Ron Ford <ron@example.invalid> said:

> On Tue, 09 Sep 2008 12:58:19 GMT, Gordon Sande posted:
>
>> On 2008-09-09 01:02:58 -0300, Ron Ford <ron@example.invalid> said:
>>
>> <snip>
>>
>>> I never have 2 matrices lying around, where both are almost triangular for
>>> different reasons.
>>>
>>> *
>>> *  Purpose
>>> *  =======
>>> *
>>> *  DHGEQZ computes the eigenvalues of a real matrix pair (H,T),
>>> *  where H is an upper Hessenberg matrix and T is upper triangular,
>>> *  using the double-shift QZ method.
>>> *  Matrix pairs of this type are produced by the reduction to
>>> *  generalized upper Hessenberg form of a real matrix pair (A,B):
>>> *
>>> *     A = Q1*H*Z1**T,  B = Q1*T*Z1**T,
>>> *
>>> *  as computed by DGGHRD.
>>>
>>> I doubt that matlab has a function designed for Karl Hessenberg's stuff.
>>> Not knowing better, it looks like it might mean something for
>>> representations.
>>
>> The usual style is that there will be some initial processing to bring
>> the general matrices to a form where the particular problem can be solved.
>> To find the required initial processing you will have to read more of the
>> documentation. In this case that means the SECOND sentence of the comment
>> block quoted above. So although DHGEQZ may not solve your problem directly
>> the pair of DGCHRD and DHGEQZ would seem to do the job. There are typically
>> many sensible reasons for breaking the larger problem into smaller parts.
>> Often there may be several schemes for doing the initial processing. Or
>> there may be easy methods for updating the initial processing that do not
>> also apply to the full problem. This is really a numerical analysis issue
>> rather than a Fortran question.
>
> I'm missing the meaning of pulling eigenvalues on a *pair* of matrices.
> When we pulled them on a square matrix in physics, we were finding
> principal axes. So the linear algebra had a physical interpretation.

A x = \lambda B x for positive definite B is a "nuts and bolts" type
physics problem. And no you do solve with A B^-1 but rather with
symmetric factors of B. Using A B^-1 is usually trotted out as a
laughably foolish way of making an easy problem hard by using
blind brute force algebra.

>> Sight unseen I would be willing to take a small bet that MatLab is likely
>> taking more trouble if even possible.
>
> Matlab being an educational tool and Hessenberg form being beyond the
> content for a semester of linear algebra, I would put up two dollars of
> risk capital to contend to the contrary.

A full two semester course would have had Hessemberg forms as the nonsymmetric
analogue of tridiagonal forms. Both of which are preliminaries to finding
eigenvalues and eigenvectors.

The guy who did Matlab was a professor of Computer Science speicalizing in
Numerical Analysis a long time ago so it is a sucker bet that all of NetLib
will be there. Look up Cleve Moler with google.


 0
g.sande (1185)
9/9/2008 8:26:41 PM
Gordon Sande <g.sande@worldnet.att.net> wrote:

> On 2008-09-09 16:16:39 -0300, Ron Ford <ron@example.invalid> said:
>
> > On Tue, 09 Sep 2008 12:58:19 GMT, Gordon Sande posted:
>
> >> Sight unseen I would be willing to take a small bet that MatLab is likely
> >> taking more trouble if even possible.
> >
> > Matlab being an educational tool and Hessenberg form being beyond the
> > content for a semester of linear algebra, I would put up two dollars of
> > risk capital to contend to the contrary.
>
> A full two semester course would have had Hessemberg forms as the nonsymmetric
> analogue of tridiagonal forms. Both of which are preliminaries to finding
> eigenvalues and eigenvectors.
>
> The guy who did Matlab was a professor of Computer Science speicalizing in
> Numerical Analysis a long time ago so it is a sucker bet that all of NetLib
> will be there. Look up Cleve Moler with google.

While you are looking such things up, look up Eispack and note its
authors. To save the 30 seconds of work that would take, I'll give the
hint that one of them is Cleve Moler, making it even more of a sucker
bet the Cleve would have used his own software in Matlab.

I used to have a copy of the source code for the original Matlab (the
arguably "public domain" one written in Fortran). I rather recall it as
being pretty much a wrapper around the Eispack and Linpack stuff. Hmm,
let's spend another 30 seconds in research...The Wikipedia reinforces my
recollection. From the history section of its Matlab article

"MATLAB was invented in the late 1970s by Cleve Moler, then chairman
of the computer science department at the University of New Mexico.[3]
He designed it to give his students access to LINPACK and EISPACK
without having to learn Fortran."

Following the reference 3 citation link on that page to Cleve's article
on the origins of Matlab (hosted at the Mathworks site), we find that
Cleve says

"In the late 1970s, following Wirth's methodology, I used Fortran and
portions of LINPACK and EISPACK to develop the first version of MATLAB."

Hessenberg forms were certainly in my undergrad education in linear
algebra. One uses them for all kinds of things, See, for example, the
algebraic Riccatti equation (important in control theory).

And where would Ron have gotten the strange idea that Matlab was solely,
or even primarily an educational product? Wow is that far from the mark
- very far - pretty much in the complete wrong direction. Matab is a
darned expensive product aimed at professional use. The NASA site where
I used to work paid over $100,00 per year for Matlab licenses. That's not exactly student prices. Perhaps Ron has only seen the educational version. One might take a hint from the fact that there is a separate educational version. That fairly obviously exists so that Mathworks can draw students into using the product, which they clearly would not do at the regular prices, and later those same students will push their employers to buy the product at the professional prices. -- Richard Maine | Good judgement comes from experience; email: last name at domain . net | experience comes from bad judgement. domain: summertriangle | -- Mark Twain   0 nospam47 (9747) 9/9/2008 9:32:34 PM On Tue, 9 Sep 2008 14:32:34 -0700, Richard Maine posted: > Gordon Sande <g.sande@worldnet.att.net> wrote: > >> On 2008-09-09 16:16:39 -0300, Ron Ford <ron@example.invalid> said: >> >>> On Tue, 09 Sep 2008 12:58:19 GMT, Gordon Sande posted: >> >>>> Sight unseen I would be willing to take a small bet that MatLab is likely >>>> have packaged the pair for ready use with access to the intermediate forms >>>> taking more trouble if even possible. >>> >>> Matlab being an educational tool and Hessenberg form being beyond the >>> content for a semester of linear algebra, I would put up two dollars of >>> risk capital to contend to the contrary. >> >> A full two semester course would have had Hessemberg forms as the nonsymmetric >> analogue of tridiagonal forms. Both of which are preliminaries to finding >> eigenvalues and eigenvectors. >> >> The guy who did Matlab was a professor of Computer Science speicalizing in >> Numerical Analysis a long time ago so it is a sucker bet that all of NetLib >> will be there. Look up Cleve Moler with google. > > While you are looking such things up, look up Eispack and note its > authors. To save the 30 seconds of work that would take, I'll give the > hint that one of them is Cleve Moler, making it even more of a sucker > bet the Cleve would have used his own software in Matlab. > > I used to have a copy of the source code for the original Matlab (the > arguably "public domain" one written in Fortran). I rather recall it as > being pretty much a wrapper around the Eispack and Linpack stuff. Hmm, > let's spend another 30 seconds in research...The Wikipedia reinforces my > recollection. From the history section of its Matlab article > > "MATLAB was invented in the late 1970s by Cleve Moler, then chairman > of the computer science department at the University of New Mexico.[3] > He designed it to give his students access to LINPACK and EISPACK > without having to learn Fortran." > > Following the reference 3 citation link on that page to Cleve's article > on the origins of Matlab (hosted at the Mathworks site), we find that > Cleve says > > "In the late 1970s, following Wirth's methodology, I used Fortran and > portions of LINPACK and EISPACK to develop the first version of MATLAB." > > Hessenberg forms were certainly in my undergrad education in linear > algebra. One uses them for all kinds of things, See, for example, the > algebraic Riccatti equation (important in control theory). > > And where would Ron have gotten the strange idea that Matlab was solely, > or even primarily an educational product? Wow is that far from the mark > - very far - pretty much in the complete wrong direction. Matab is a > darned expensive product aimed at professional use. The NASA site where > I used to work paid over$100,00 per year for Matlab licenses. That's
> not exactly student prices. Perhaps Ron has only seen the educational
> version. One might take a hint from the fact that there is a separate
> educational version. That fairly obviously exists so that Mathworks can
> draw students into using the product, which they clearly would not do at
> the regular prices, and later those same students will push their
> employers to buy the product at the professional prices.

Well, jeez all frickin mighty, I stand corrected.

Gordon's claim that Hessenberg forms are a prelim to doing eigenvalues/
vectors is likely more the case for research as opposed to education.  One
can do a 3x3 by hand.  I just found the Gilbert strang text I have for
linear algebra, and there is no entry for Hessenberg in the index.

I'm not above sending the cat two bucks.  Indeed, I stash cash in my old
books and netted $48 on the transaction. UNM is just down the hill for me. It might be worth a little poking around the CS department and getting the fuller story. Sometimes, such departments are very generous with Joe Public using their resources. -- War will never cease until babies begin to come into the world with larger cerebrums and smaller adrenal glands. 2 H. L. Mencken   0 ron7715 (217) 9/9/2008 11:34:22 PM Ron Ford wrote: .... > UNM is just down the hill for me. It might be worth a little poking around > the CS department and getting the fuller story. Sometimes, such > departments are very generous with Joe Public using their resources. Which "fuller story" you're after is beyond me, but it's been over 20 years since Cleve was at UNM since TMW (The Mathworks, the company that produces Matlab) was founded in 1984. The story from Cleve's pen is at http://www.mathworks.com/company/newsletters/news_notes/clevescorner/dec04.html It's actually pretty interesting reading as it chronicles much of the development of early matrix computational methods. --   0 none1568 (7453) 9/10/2008 12:23:03 AM Richard Maine wrote: > And where would Ron have gotten the strange idea that Matlab was solely, > or even primarily an educational product? Wow is that far from the mark > - very far - pretty much in the complete wrong direction. I might believe for research as opposed to production work, and some might consider research as part of education. (Both have the goal of learning.) For production work (solving the same equations over and over with different input data) rewriting in Fortran would be more usual. -- glen   0 gah (12851) 9/10/2008 1:22:57 AM glen herrmannsfeldt wrote: > Richard Maine wrote: > >> And where would Ron have gotten the strange idea that Matlab was solely, >> or even primarily an educational product? Wow is that far from the mark >> - very far - pretty much in the complete wrong direction. > > > I might believe for research as opposed to production work, > and some might consider research as part of education. > (Both have the goal of learning.) For production work > (solving the same equations over and over with different > input data) rewriting in Fortran would be more usual. > Research may or may not have the goal of learning, but often is more about getting research grants to stuff the coffers. > -- glen > -- Gary Scott mailto:garylscott@sbcglobal dot net Fortran Library: http://www.fortranlib.com Support the Original G95 Project: http://www.g95.org -OR- Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html If you want to do the impossible, don't hire an expert because he knows it can't be done. -- Henry Ford   0 garylscott (1355) 9/10/2008 1:28:18 AM glen herrmannsfeldt wrote: > Richard Maine wrote: > >> And where would Ron have gotten the strange idea that Matlab was solely, >> or even primarily an educational product? Wow is that far from the mark >> - very far - pretty much in the complete wrong direction. > > I might believe for research as opposed to production work, > and some might consider research as part of education. > (Both have the goal of learning.) For production work > (solving the same equations over and over with different > input data) rewriting in Fortran would be more usual. Depends on the particular model I think. There are quite a number of production applications in Matlab although generally they're tied around the graphics or other specialized abilities of Matlab. A "traditional" number-cruncher only, I'd agree although even there I think it wouldn't necessarily be hard to find applications which use mex-files in C/C++ or Fortran to do the really heavy computations that would qualify imo as "production". --   0 none1568 (7453) 9/10/2008 1:42:51 AM On Tue, 09 Sep 2008 19:23:03 -0500, dpb posted: > Ron Ford wrote: > ... >> UNM is just down the hill for me. It might be worth a little poking around >> the CS department and getting the fuller story. Sometimes, such >> departments are very generous with Joe Public using their resources. > > Which "fuller story" you're after is beyond me, but it's been over 20 > years since Cleve was at UNM since TMW (The Mathworks, the company that > produces Matlab) was founded in 1984. > > The story from Cleve's pen is at > > http://www.mathworks.com/company/newsletters/news_notes/clevescorner/dec04.html > > It's actually pretty interesting reading as it chronicles much of the > development of early matrix computational methods. Interesting reading. I had other business downtown today and stopped at UNM to poke around. There wasn't much at the CS dept except proximity to the engineering library, where a person could thumb through fortran-related materials. They had a manual for Lapack and Eispack, which provided the clearest explanations for Hessenberg forms that I had yet to read. They have MR&C online now for students and faculty. More interesting and fortranny was the physics department, where they had monographs posted of cosmological computations with fortran. I was impressed with how much the pictures of graduate students and faculty compared to what Republicans think terrorists are. They were unapologetically ethnic and brown and didn't wear a flag lapel, which seems to indicate how people feel about a policy of indiscriminate harming of civilians. The grad student I talked to in the CS dept didn't know who Cleve Moler was. Go figure. -- Wealth - any income that is at least one hundred dollars more a year than the income of one's wife's sister's husband. 6 H. L. Mencken   0 ron7715 (217) 9/11/2008 12:49:55 AM  Reply: Similar Artilces: Error while obtaining sizes from MEX S-function 'forward' in block 'dummy/Dynamic_Model/S-Function'. MATLAB error message:. Hi to everybody, I created the file forward.dll using the command: mex -DWIN32 -output forward model_d.c model_s.c sdlib.c assigns.c contact.c derivs.c gmc.c impact.c inits.c invert.c lcp_solver.c lmdif_c.c mathtools.c object.c output.c pipetools.c readmuscles.c readtools.c sdfor.c spring_based.c wrapping.c gcvspl.c user_def.lib forward.lib acpp.lib qhull.lib solid.lib wrap.lib I need to run the command: set_param([subsystemname,'/','S-Function'],'function name','forward','parameters','[0],[0],[0],[0],[0],[0],[1 0 0 0 20],[0]'); ... Matlab Equivalent Function for Fortran Convention I am attempting to convert the attached Fortran source code (for a Laplacian five point smoothing filter) to a Matlab m-file. Within the attached Fortran code, there occasionally appears a Fortran convention known as an "S edit descriptor". For example, in line 14: SMFAC=FSM(I+1,J)+FSM(I,J-1)+FSM(I-1,J)+FSM(I,J+1)+1.S-5 In Fortran, the "S edit descriptor" restores the plus sign as optional for all subsequent positive numeric fields. It restores to the processor the discretion of producing plus characters on an optional basis. It takes the following form: S I can't f... MatLab's 'movie' function Hi! Using MatLab's 'movie' function you can play a movie recorded by the 'getframe' command. It is possible to specify the number of times the movie is played and the frames per second. Unfortunately, I've not found a way to stop the playback of a movie. Is it possible to, let's say I've specified the movie should be played 20 times, to disrupt the playback after an user interrupt?! Thanks a lot, Chris On Sat, 12 Feb 2005 10:40:06 +0100, Christoph ROLZ wrote: >Hi! > >Using MatLab's 'movie' function you can play a movie recorded by the >'getframe' command. It is possible to specify the number of times the >movie is played and the frames per second. > >Unfortunately, I've not found a way to stop the playback of a movie. > >Is it possible to, let's say I've specified the movie should be played >20 times, to disrupt the playback after an user interrupt?! > >Thanks a lot, > Chris if you want to play the movie, tried thi command index is the number of frame in video file. index = 1:100 mov = aviread('filename',index) for i = 1: 100 frame = mov(i).cdata; imshow(frame) end Please try it. ... Matlab's 'graycomatrix' function I have one question: Is Matlab's 'graycomatrix' function actually in accordance with original Haralick's 1973 paper? I mean, are they supposed to be the same algorithm? If yes, I don't think Matlab did a good job on this. For example, try it on this matrix (i.e., 'image'): 0 0 1 1 0 0 1 1 0 2 2 2 2 2 3 3 This matrix is in Haralick's original paper and the results can be compared. Can anybody ellaborate if you used it? Thank you. "Bulent Bayraktar" <bayrakta@purdue.edu> writes: > I have one question: Is Matlab's 'graycomatrix' function actually in > accordance with original Haralick's 1973 paper? > I mean, are they supposed to be the same algorithm? If yes, I don't > think Matlab did a good job on this. > > For example, try it on this matrix (i.e., 'image'): > 0 0 1 1 > 0 0 1 1 > 0 2 2 2 > 2 2 3 3 > > This matrix is in Haralick's original paper and the results can be > compared. > > Can anybody ellaborate if you used it? You do need to understand a bit about the conventions used in the software you are using. For example, the Image Processing Toolbox's default black-to-white range for double-precision inputs is [0, 1]. The reference page for graycomatrix describes in detail what it does. By default, for example, it quantizes the range [0, 1] into 8 levels, resulting in an 8-by-8 co-occurrence matrix. But for your matrix, it is seeing 5 &qu... what's the equivalent of substring function in Matlab? Simple question: I have a string like this 'blah blah [123] more blah 586 aavf', and I want to extract the number that's enclosed in '[' and ']'. I thought I can use findstr() to locate the position of '[' amd ']', then I use a substring function to get 123, but I can't find substring function in Matlab. Any thoughts? tline = 'blah blah [123] more blah 586 aavf'; ileft = findstr('[', tline); iright = findstr(']',tline); % now what the substring function that I can get something like substring(tt, ileft, iright)? thanks ... Fortran's INCLUDE statement in Matlab??? Hi: In Fortran, one can use the INCLUDE statement to hide a piece of source code (stored externally in a text file) from the main program to enhance readability. In Matlab, how can I do that? What is wrong with a simple script? >> help script SCRIPT About MATLAB scripts and M-files. A SCRIPT file is an external file that contains a sequence of MATLAB statements. By typing the filename, subsequent MATLAB input is obtained from the file. SCRIPT files have a filename extension of ".m" and are often called "M-files". To make a SCRIPT fi... Is there a Fortran equivalent of C's #ifdef ?? I'm trying to write three shell scripts, which determine if the C/C++/Fortran compilers are GNU, Sun, IBM. HP etc. The code below is makes use of the C pre-processor and checks for what macros are defined. Can anyone give me a clue how I might do similar in Fortran? drkirkby@swan:[~]$ cat testcc #!/usr/bin/sh # Determine the type of C compiler, which can later # be used to determine the flags the compiler # will want. Do this by defining pre-processing a bit # of C code, and checking what are defined. # The Sun and GNU compilers have been tested. # The HP and GNU compilers have not been tested, but # use information gained from the documentation. # HP-UX C and C++ compiler. # http://docs.hp.com/en/7730/newhelp0610/preprocess.htm # IBM Compiler Reference - XL C/C++ for AIX, V10.1 # http://www-01.ibm.com/support/docview.wss?uid=swg27012860&aid=1 # Using HP C++ for Tru64 UNIX and Linux Alpha # http://h30097.www3.hp.com/cplus/ugu_impl.html#implem_chap # First, make sure the enviroment variable CC is defined. if [ -z "$CC" ]; then echo "Sorry, you should define the enivronment variable CC" exit 1 fi # Create a test file. It does not need to be a complete # C++ file, as it is only pre-processed. So there is no # need for a 'main' TESTFILE=/tmp/test.$$.c # The flags for the GNU compilers do not change with # operating system, so there is no need to worry too # much about what system this is on. echo "#ifdef __GNUC__&... equivalent of IDL's 'execute' function? In IDL there is a function: execute(mystring) which will execute whatever command is contained within the string 'mystring'. This is very helpful, for example, when you are reading a file which has a list of variable names and associated data values. You would like to create MATLAB variables with the names listed in the file and assign the data values to these (initially unknown) variable names. Is there any way to do this in MATLAB? For this example, 'mystring' would be defined by something like: mystring=strcat(varname,'=data_array') Emily Riddle wrote: > >... MATLAB The current version of MATLAB, as far as one can see on the table presented on their pages, offers "support" (not maybe an exact term this) for Intel's fortran compiler v.10.1. Is it perhaps known when in the future versions v.11.0 will be supported ? I know it cannot be known for certain, but circa ... next version, second next from now ? With regards to all, Paul Paul Huber <phuber@invalid.com> wrote in message <oossd55julsqn3i9au2r4sup4elpnaih2c@4ax.com>... > The current version of MATLAB, as far as one can see on the table > presented on their pages, off... Postgresql equivalent for MySQL's 'rollup' function? I'm beginning to move a very simple set of php scripts from MySQL to Postgresql and want to know if Postgresql has anything like MySQL's rollup function. I use several scripts that pull out time and dollar data, break it out by time period and have a total at the bottom. Anything like that? I haven't stumbled across anything yet. thanks, r rloef@interfold.com wrote: > I'm beginning to move a very simple set of php scripts from MySQL to > Postgresql and want to know if Postgresql has anything like MySQL's > rollup function. I use several scripts that pull out time and dollar > data, break it out by time period and have a total at the bottom. > Anything like that? I haven't stumbled across anything yet. > > thanks, > > r > I'm not an expert of MySQL, but the documentation says that the "WITH ROLLUP modifier" of the GROUP BY clause in the SELECT statement gives you the kind of query result you described, that should be: 1999$1500 2000 $1400 2001$100 (Total) $3000 In PostgreSQL you could do this by using a UNION between 2 queries. Consider this: CREATE TABLE public.sales ( year varchar(4), --other fields, for example product name, customer code, ... price float4 --money is deprecated. For more precision, you should use NUMERIC ); (Now, insert some data...) And run the following query: SELECT year, SUM(price) FROM sales ... what's wrong with "make check-fortran"'s result of gfortran 20071130? FAIL: gfortran.dg/bind_c_usage_16.f03 -O0 execution test FAIL: gfortran.dg/bind_c_usage_16.f03 -O1 execution test FAIL: gfortran.dg/bind_c_usage_16.f03 -O2 execution test FAIL: gfortran.dg/bind_c_usage_16.f03 -O3 -fomit-frame-pointer execution test FAIL: gfortran.dg/bind_c_usage_16.f03 -O3 -fomit-frame-pointer - funroll-loops execution test FAIL: gfortran.dg/bind_c_usage_16.f03 -O3 -fomit-frame-pointer - funroll-all-loops -finline-functions execution test FAIL: gfortran.dg/bind_c_usage_16.f03 -O3 -g execution test FAIL: gfortran.dg/bind_c_usage_16.f03 -Os execution test all the... 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...

Fortran equivalent of Matlab
1) is there an equivalent of the "sparse" in fortran 90/95 2) is there a short-cut way of solving a system of linear equations (Ax=b) in fortran 90/95? Basically, i am looking for an equivalent of x=A\b. "Vinit Singh" <vinitsingh355@gmail.com> wrote in message news:<eef4ff7.-1@webx.raydaftYaTP>... > 1) is there an equivalent of the "sparse" in fortran 90/95 > > 2) is there a short-cut way of solving a system of linear equations > (Ax=b) in fortran 90/95? Basically, i am looking for an equivalent of > x=A\b. (1) The concept of sparse ...

Fortran S-function
Any body know if it is possible to use more than 1 fortran s-function as mex inside simulink model. I tried this by following command and got this error ___________________________________________________________ mex sfun_hyd_for.f interpolation.f simulink.f interpolation.obj : error LNK2005: _SIZES@4 already defined in sfun_hyd_for.obj interpolation.obj : error LNK2005: _INITCOND@4 already defined in sfun_hyd_for.obj interpolation.obj : error LNK2005: _DERIVS@16 already defined in sfun_hyd_for.obj interpolation.obj : error LNK2005: _OUTPUT@16 already defined in sfun_hyd_for.obj interpolati...

How to call a component's callback function in another component's callback function
How to call a component's callback function in another component's callback function? I want to call popup menu's call back function in push button's call back function. What should I do and how? I will be grateful to you for you help! Thank you, Regards, Ahmed Just call it like you would any other function. The only thing you have to worry about is parsing arguments in the callback that is called from multiple sources. This example illustrates the difference: %---------------------------------------------------------------------------------------% function [] = call...

It's stupid but I don't know fortran :-(((
I must write in a file the array value. I'd like to have in file this format 1 value of element array(2) 2 value of element array(3) 3 value of element array(4) etc I wrote this code but I don't know get the up format. How can I have CR, In Language C I use \n. open(8, file='headm.txt') write(8,*) (i, headm(i) i=1,n+1) close(8) Ciobin wrote: > > I must write in a file the array value. > > I'd like to have in file this format > > 1 value of element array(2) > > 2 value of element array(3) > > 3 value of element array(4) > > etc > > I wrote this code but I don't know get the up format. How can I have CR, In > Language C I use \n. > > open(8, file='headm.txt') > > write(8,*) (i, headm(i) i=1,n+1) > > close(8) one way is do i i=1, iSizeOfHeadm write(*,*) i, headm(i) enddo > open(8, file='headm.txt') > write(8,*) (i, headm(i) i=1,n+1) > close(8) The easiest way is probably to write a real do loop (equivalent of a simple for loop in C): open(8, file='headm.txt') do i = 1, n+1 write(8,*) i, headm(i) end do close(8) -- FX You have two requirements, the first regarding which elements to write and the second regarding the arrangement of the output. There are two ways to do this. The first is to use a loop, so that each WRITE statement writes one line (the next write statement begins a new line): ...

Does anybody know a way to convert Matlab code into Fortran and then compile Fortran mex dll file for Matlab 2006a?
Hi all, I want to ask three questions regarding Fortran and Matlab interface. The two tools I am using are: Intel Visual Fortran 10.1 and Matlab 2006a. Q1. What is the best converter to convert Matlab code into Fortran code with readability? My understanding is that Fortran and Matlab are both vectorized and they should be pretty similar and such converter should do a good job. Q2. Is there a wizard for Intel Visual Fortran under MS Visual Studio.Net 2003 or Visual Studio.Net 2005 to set up environments for building mex dll file for Matlab on Windows XP? There is such a wizard tool for VC/C++, which is very convenient, just create a MEX project in Visual Studio and the compiled the result will be a mex dll for use in Matlab. I hope there is a similar tool for Fortran? Q3. Is there a tool to convert the Matlab code into Fortran with readability and then automatically make itself a mex dll? Thanks a lot! On Jul 6, 9:49 pm, "Linus Utopia" <linus_uto...@gmail.com> wrote: > Hi all, > > I want to ask three questions regarding Fortran and Matlab interface. The > two tools I am using are: Intel Visual Fortran 10.1 and Matlab 2006a. > > Q1. What is the best converter to convert Matlab code into Fortran code with > readability? My understanding is that Fortran and Matlab are both vectorized > and they should be pretty similar and such converter should do a good job. > > Q2. Is there a wizard for Intel Visual Fortran under ...

ndefined function or variable 'y'. The first assignment to a local variable determines its class. Function 'Embedded MATLAB Function' (#52.384.385), line 19, column 2: "y"
Hi everybody I have a serious problem and i need your help. i use embedded matlab function in simulink to generate some matrices which i use as input to other bloc on simulink. But i got this error while the simulation is running: Undefined function or variable 'y'. The first assignment to a local variable determines its class. Function 'Embedded MATLAB Function' (#52.384.385), line 19, column 2: "y" My code is function y = fcn(u) Ap=[0.9580 0 0 0;0 0.9418 0 0;0 0 0.9048 0;0 0 0 0.9277]; Bp=[0.25 0;0.25 0;0 0.5;0 0.5]; Cp=[0.1678 0 0.9516 0;0 0.2329 0 0.2890]; [m1,n1]=size(Cp); [n1,n_in]=size(Bp); A_e=eye(n1+m1,n1+m1); A_e(1:n1,1:n1)=Ap; A_e(n1+1:n1+m1,1:n1)=Cp*Ap; B_e=zeros(n1+m1,n_in); B_e(1:n1,:)=Bp; B_e(n1+1:n1+m1,:)=Cp*Bp; C_e=zeros(m1,n1+m1); C_e(:,n1+1:n1+m1)=eye(m1,m1); y(1:m1,:)=C_e; for kk=1:u-1; y((m1*kk)+1:m1*(kk+1),:)=y(m1*(kk-1)+1:m1*kk,:)*A_e; end thank you so much On 07/16/2014 5:50 AM, AGUEMON wrote: .... .... > ...i got this error while the simulation is > running: > > Undefined function or variable 'y'. The first assignment to a local > variable determines its class. > Function 'Embedded MATLAB Function' (#52.384.385), line 19, column 2: > "y" > .... > C_e(:,n1+1:n1+m1)=eye(m1,m1); > y(1:m1,:)=C_e; > > for kk=1:u-1; > y((m1*kk)+1:m1*(kk+1),:)=y(m1*(kk-1)+1:m1*kk,:)*A_e; .... Never used the em...

convert a 'C' code to 'Fortran'
Hi all, Is there a program available that can convert a code in 'C' to 'Fortran'? I have a 'C' program (quite big) that I need to integrate into an existing 'Fortran' code. Can anyone give me a direction? Thanks in advance. Sam. Sam: http://home.cfl.rr.com/davegemini/C2F.ZIP Unzip and read the README.C2F text file. Skip On 10 Nov 2004 11:33:34 -0800, atluris@gmail.com (sam) wrote: -|Hi all, Is there a program available that can convert a code in 'C' to -|'Fortran'? I have a 'C' program (quite big) that I need to integrate -|into an...

convert 'C' code to 'Fortran'
Hi, Can anyone help me find a software that can convert a code in 'C' to 'Fortran77/90' automatically? Thanks in advance. Sam. sam wrote: > Hi, > Can anyone help me find a software that can convert a code in 'C' > to 'Fortran77/90' automatically? > > Thanks in advance. > > Sam. Wow, - good luck :) sam wrote: > Hi, > Can anyone help me find a software that can convert a code in 'C' > to 'Fortran77/90' automatically? This is not really on-topic. However, there is a slightly more topical version: Why...

Matlab
Hi everyone, I'm trying to write code for the c2d function in Matlab - where the inputs are state matrices A, B, C, D, and a delta time-step. The outputs are [phi] and [gamma], the a and b matrices of the new, discrete state representation. I'm not sure where to start. Can anyone offer any suggestions? Thanks ...

Fortran to Matlab
I'm converting a Fortran program over to Matlab. I've done the conversion and the time domain part gives the same answers, but the frequency domain part does not. I've looked over each line and everything seems fine. So I began to suspect the sin, cos and tan functions. I created a table in Fortran and in Matlab, and indeed they do not match: From Fortran: sin cos tan 0.0 1.0 0.0 0 1.0 -0.0 -22877332 pi/2 -0.0 -1.0 0.0 pi -1.0 -0.0 22877332 -pi/2 0.0 -1.0 -0.0 -pi From Matlab: sin cos tan 0 1.00 0 0 1.00 0.00 16331239353195370.00 pi/2 0.00 -1.00 -0.00 pi -1.00 0.00 -16331239353195370.00 -pi/2 -0.00 -1.00 0.00 -pi where the column after tan is the value I plugged into the trig functions. I'm not seeing any pattern to the differences. Anyone know what the differences are between Fortran and Matlab trig functions, and how to 'correct it' in Matlab? Thanks [Tim] On Friday, September 14, 2012 7:41:08 AM UTC+12, Tim wrote: > I'm converting a Fortran program over...

how to export function from matlab to fortran
i need to write some code in fortran ,and i have problem how to export function(i wrote funct) to fortran from matlab(m file).I'we read some about mexx but i dont understand all. If you need to keep your function in fortran for some reason, then mex is the way to go. Read more about it (go to the mathworks website). There are example functions and gateways in the help docs. Why not program in native matlab? Or convert it from fortran: http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=5260&objectType=file HTH, Ben Golubovic Goran wrote: > i need to write...

Web resources about - Fortran equivalent to Matlab's eig() function - comp.lang.fortran

Resources last updated: 3/25/2016 9:54:40 AM