help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What should I do to fix "warning: implicit conversion from real matr


From: John B. Thoo
Subject: Re: What should I do to fix "warning: implicit conversion from real matrix to real scalar"?
Date: Wed, 8 Jul 2009 14:08:58 -0700


On Jul 8, 2009, at 12:14 PM, Carlo de Falco wrote:


On 8 Jul 2009, at 20:06, John B. Thoo wrote:

Hi, Carlo. Thanks for the tip. So, then, is using "trapz" in the following way my only recourse to find \int H(u(:,t)) dx for some function H(x) where u(x,t) is a matrix?

It is not the only option but it is the safest bet if you
don't know anything else about your data...

%%--------begin energy.m---------
clear all

global u;
load ht_tf8M160ord9visc01.mat;

function y = h (x)
global u;

 U = u(:,5);
 y = (U.^2).';

endfunction

trapz (x, h (x))
%%---------end energy.m----------


there's no reason to define a function for calling trapz, you can just do

%%--------begin energy.m---------
load ht_tf8M160ord9visc01.mat
trapz (x, u(:,5).^2)
%%---------end energy.m----------


Or is there a way I can use either "quad" or "quadl"?  Thanks again.

there is no point in using quad or quadl in this case.
c.

Brilliant!

%%--------begin energy.m---------
load ht_tf8M160ord9visc01.mat
trapz (x, u(:,5).^2)
%%---------end energy.m----------

works perfectly. (It wasn't apparent to me from the documentation that defining a function isn't required.) Thank you for your help and your patience. :-)

---John.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]