필터 지우기
필터 지우기

Chebyshev differential matrices code not callable

조회 수: 1 (최근 30일)
Lukgaf
Lukgaf 2018년 3월 19일
댓글: Lukgaf 2018년 3월 19일
This is the code by tretfen (cheb.m):
% CHEB compute D = differentiation matrix, x = Chebyshev grid
function [D,x] = cheb(N)
if N==0, D=0; x=1; return, end
x = cos (pi*(0:N)/N)';
c = [2; ones(N-1,1); 2].*(-1).^(0:N)';
X = repmat(x,1,N+1);
dX = X-X';
D = (c*(1./c)')./(dX+(eye(N+1))); % off-diagonal entries
D = D - diag(sum(D')); % diagonal entries
  댓글 수: 2
Walter Roberson
Walter Roberson 2018년 3월 19일
What parameter are you passing? What error message are you encountering?
Lukgaf
Lukgaf 2018년 3월 19일
Thanks, Not enough input arguments.
Error in cheb (line 4)
if N==0, D=0; x=1;

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2018년 3월 19일
You have to go down to the command line and call the function passing in a non-negative integer. For example,
[differ_matrix, cheb_grid] = cheb(19)
  댓글 수: 3
Walter Roberson
Walter Roberson 2018년 3월 19일
I stored the code you posted in the file cheb.m and then I went to the command line and there I commanded
[differ_matrix, cheb_grid] = cheb(19)
and I got back results.
You cannot run that function just by clicking on the green Run button: you must go to the command line to run it so that you can pass in a value for N.
Lukgaf
Lukgaf 2018년 3월 19일
Thanks

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by