필터 지우기
필터 지우기

The command is working perfectly in the command window but not as a script

조회 수: 13 (최근 30일)
ToTo
ToTo 2013년 10월 16일
댓글: dpb 2013년 10월 19일
Hi all,
I try to run this script:
[t y] = rk4sys(@lorenz,[0 20],[5 5 5],0.03125);
plot(t,y)
plot(y(:,1), y(:,2)), xlabel('x'), ylabel('y')
plot(y(:,1), y(:,3)), xlabel('x'), ylabel('z')
plot(y(:,2), y(:,3)), xlabel('y'), ylabel('z')
Where the called function lorenz is:
function [ yp ] = lorenz( t,y )
yp = [-10*y(1)+10*y(2);28*y(1)-y(2)-y(2)*y(3);-(8/3)*y(3)+y(1)*y(2)];
end
it gives error:
Error in ==> lorenz at 3
yp = [-10*y(1)+10*y(2);28*y(1)-y(2)-y(2)*y(3);-(8/3)*y(3)+y(1)*y(2)];
However, when i copy that script in the command window it works.
  댓글 수: 15
ToTo
ToTo 2013년 10월 18일
i mean iwill keep going with my work in MatLab. Thank You all

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

답변 (1개)

Yannick
Yannick 2013년 10월 17일
Just to close the loop on this, the bottom line is that MATLAB file names, just like MATLAB variable or function names, can only contain letters (both lower- and upper-case), digits and underscores. Additionally, they must start with a letter (i.e., cannot start with a digit or an underscore).
In particular, spaces and dashes (-) are not valid characters in function, script and variable names.
  댓글 수: 5
Daniel Shub
Daniel Shub 2013년 10월 19일
@dpb While I am not aware of any "magic" filenames putting files in directories that start with @ or + can cause very unexpected behavior.
dpb
dpb 2013년 10월 19일
Not sure what that has to do with the proper description of allowable m-file naming though???

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

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by