English 中文(简体)
Matlab: 数量矢量部分
原标题:Matlab: definite integral of numerical vectors

i m 寻求解决两个病媒的有限组成部分,我试图解释。

我知道:数字载体和数字的G(z)矢量。

融合的极限为zmin和zmax。

I should to calculate: Integral between zmin,zmax of [G(z) * z^(7/6)] dz

我能否用以下法典解决?

For i = zmin:zmax
myresult = G(z(i))*z(i)^(7/6)
end
问题回答

(前)

您可使用

Define G(z) as a function handle, and the function to be integrated as another one. You can find an example in my other answer.


因此,你的目标是计算<代码>[G(z) * z^(7/6)] * dz,其中G(z)z为预估数字矢量,dz为小增量值。

dz = (zmax - zmin) / length(G(z));
S = G * z  * dz;

<代码>S应为结果。 让我解释一下。

  • First of all, I messed up with G(z) previously (apologize for that). You have already evaluated (partially) the function to integrate, namely G(z) and z.
  • G(z) and z are number arrays. Arrays are indexed by integer, starting from 1. So G(z(i)) may not be a valid expression, as z(i) haven t been guaranteed to be integers. The code above only works correctly if you have defined G(z) in this way - G(i) = some_function (z(i));. By so each element of the same index in two arrays have a meaningful relation.
  • There are several ways to evaluate the product of two arrays (vectors), generating a single-value sum. A for loop works, but is inefficient. G * z is the way to calc vector dot product.




相关问题
java.util.Vector - alternatives

Previously I would always have thought a Vector was good to use for non-descript objects when length was unknown. As far as I was aware I thought it was thread-safe too What would change that Vector ...

Questions about vector, union, and pointers in C++

The questions I have are NOT homework questions, but I am considering using these concepts in my assignment. The context, if it helps, is like this: I need to keep track of several union instances and ...

c++ problem with polymorphism and vectors of pointers

Consider the following example code: class Foo { }; class Bar : public Foo { }; class FooCollection { protected: vector<shared_ptr<Foo> > d_foos; }; class BarCollection : public ...

matrix and vector template classes in c++

#include <array> template <typename T> class Vector4<T> { std::array<T, 4> _a; // or T _a[4]; ? }; template <typename T> class Matrix4<T> { std::array<...

sort vector by more than 1 field

How do I sort the below code by name, age and score... all three fields #include <string> #include <vector> #include <algorithm> struct student_t { std::string name; ...

Best way to store and retrieve this..?

I ve been trying all night, and talk of maps, arrays, vectors and hash_maps have filled my head. im just confused now. i posted a previous question here: C++ map really slow? problem was fixed but it ...

热门标签