when i'm trying to run the below program, it is showing the following error. ??? Undefined function or variable 'z'. Error in ==> integration at 6 I=integrat​e(z*(cosh(​k*(d+z)))^​2,z,0,hc);

1 回表示 (過去 30 日間)
the program is as follows:
clc;
d=input('d=');
L=input('L=');
hc=input('hc=');
k=2*pi/L;
I=integrate(z*(cosh(k*(d+z)))^2,z,0,hc)
Someone please help me...
thank you
  1 件のコメント
Carlos
Carlos 2013 年 2 月 18 日
Have you declared z as a symbolic a variable within your function integrate?

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2013 年 2 月 18 日
You are confusing numeric integration with symbolic integration.
symbolic integration uses int() instead of integrate(), and requires that the free variable have been pre-defined as a symbol (unless quoted strings are passed in.) symbolic integration requires the integration variable as the second parameter, the way you have passed it in.
syms z
I_symbolic = int(z*(cosh(k*(d+z)))^2,z,0,hc));
I_numeric = double(I_symbolic);
Numeric integration cannot have any free variables, and must have a function as its first parameter. The second parameter is never the variable of integration for numeric integration.
I_numeric = integrate(@(z) z*(cosh(k*(d+z)))^2,0,hc);
  1 件のコメント
Aiswaria
Aiswaria 2013 年 2 月 18 日
i tried that but its saying like ??? Undefined function or method 'integrate' for input arguments of type 'function_handle'.
Error in ==> integration at 7 I_numeric = integrate(@(z) z*(cosh(k*(d+z)))^2,0,hc)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by