フィルターのクリア

how to define a function

1 回表示 (過去 30 日間)
dcydhb dcydhb
dcydhb dcydhb 2019 年 1 月 2 日
コメント済み: Walter Roberson 2019 年 1 月 2 日
i just want to define a function of two variables,the
c_x_y=2/d*(int(cos(x*pi/d*z)*zy,z,0,d));
and x,y belongs to intergers form 0,if a change it to the Specific numbers, it will calculate the values such as
c_0_0=2/d*(int(cos(0*pi/d*z)*z0,z,0,d));
c_0_1=2/d*(int(cos(0*pi/d*z)*z1,z,0,d));
c_0_2=2/d*(int(cos(0*pi/d*z)*z2,z,0,d));
c_0_3=2/d*(int(cos(0*pi/d*z)*z3,z,0,d));
c_0_4=2/d*(int(cos(0*pi/d*z)*z4,z,0,d));
c_0_5=2/d*(int(cos(0*pi/d*z)*z5,z,0,d));

回答 (2 件)

madhan ravi
madhan ravi 2019 年 1 月 2 日
Just create a function with an input that changes and the just call it to find the integral.
doc function% read it

Walter Roberson
Walter Roberson 2019 年 1 月 2 日
syms x y z d pi
c_x_y = @(x,y) 2/d*(int(cos(x*pi/d*z)*sym(sprintf('z%d',y)),z,0,d));
This expects y to be a non-negative integer in order to generate the zy variable properly.
x is not required to be an integer. When it is a non-zero integer, then c_x_y will come out as 0.
  2 件のコメント
dcydhb dcydhb
dcydhb dcydhb 2019 年 1 月 2 日
why got this?
clc;
clear all;
close all;
syms x y z d pi
syms c_1_1
x=1;
y=1;
c_x_y = @(x,y) 2/d*(int(cos(x*pi/d*z)*sym(sprintf('z%d',y)),z,0,d))
c_1_1
got this
c_x_y =
@(x,y) 2/d*(int(cos(x*pi/d*z)*sym(sprintf('z%d',y)),z,0,d))
c_1_1 =
c_1_1
Walter Roberson
Walter Roberson 2019 年 1 月 2 日
syms c_1_1
does not invoke c_x_y with parameters (1,1) . You would need
c_1_1 = c_x_y(1,1)

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

カテゴリ

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

タグ

製品


リリース

R2007a

Community Treasure Hunt

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

Start Hunting!

Translated by