我编辑的matlab函数老是出现这种问题:Error using spirallength (line 9) Not e

学习 时间:2026-03-30 09:04:38 阅读:9683
我编辑的matlab函数老是出现这种问题:Error using spirallength (line 9) Not enough input arguments.function varargout = spirallength(d,n,varargin)%SPIRAL \x09\x09\x09\x09\x09画出螺旋线或螺旋条带Nin = length(varargin) + 1;% error(nargchk(1,Nin,nargin))if nargout > 1error('Too many output arguments!')endj = sqrt(-1);phi = 0:pi/20 :n*2*pi;amp = 0:d/40 :n*d;spir = amp .* exp(j*phi);if nargout==0switch Nincase 1plot(spir,'b')case 2d1=varargin{1};amp1 = (0:d/40 :n*d) + d1; spir1 = amp1 .* exp(j*phi);plot(spir,'b');hold on;plot(spir1,'b');hold offotherwise d1=varargin{1};amp1 = (0:d/40 :n*d) + d1; spir1 = amp1 .* exp(j*phi);plot(spir,varargin{2:end});hold on;plot(spir1,varargin{2:end});end;axis('square')elsephi0 = 0:pi/1000 :n*2*pi;amp0 = 0:d/2000 :n*d;spir0 = amp0 .* exp(j*phi0);varargout{1} = sum(abs(diff(spir0)));if Nin>1d1=varargin{1};amp1 = (0:d/2000 :n*d) + d1; spir1 = amp1 .* exp(j*phi);varargout{2} = sum(abs(diff(spir1)));end;end

最佳回答

甜蜜的百褶裙

朴实的含羞草

2026-03-30 09:04:38

是说spirallength 这个函数你在使用的时候,输入参数不够,。你怎么调用这个函数的 再问: 我刚学,我直接调用书籍里面的粒子,打开后直接运行的 再答: 你刚学就学这么复杂的??、、、你这似乎还没懂matlab函数的概念啊。。。再问: 我捣鼓明白了函数文件和M文件有区别 的 ,如果我直接在编译器中运行 也会发生这样错误;我就是直接运行的。操作方式不对

最新回答共有2条回答

  • 粗暴的中心
    回复
    2026-03-30 09:04:38

    是说spirallength 这个函数你在使用的时候,输入参数不够,。你怎么调用这个函数的 再问: 我刚学,我直接调用书籍里面的粒子,打开后直接运行的 再答: 你刚学就学这么复杂的??、、、你这似乎还没懂matlab函数的概念啊。。。再问: 我捣鼓明白了函数文件和M文件有区别 的 ,如果我直接在编译器中运行 也会发生这样错误;我就是直接运行的。操作方式不对

上一篇 The ------ from the customers who have tried the new mobile

下一篇 x的二次方-2x-4=0求过程.