Question: Hello there, I need help to solve the matlab coding error. I need to combine these two functions together and run on MATLAB but I

Hello there, I need help to solve the matlab coding error. I need to combine these two functions together and run on MATLAB but I got an error, it mentions not enough input arguments. PLEASE HELP ME. first code:

function s = inspiral(n) %SPIRAL SPIRAL(n) is an n-by-n matrix with elements ranging % from 1 to n^2 in a rectangular spiral pattern. % Copyright 1984-2002 The MathWorks, Inc. % $Revision: 5.7 $ $Date: 2002/04/15 03:34:37 $ % Start in the center. s = zeros(n,n); i = ceil(n/2); j = ceil(n/2); s(i,j) = n*n; if n==1, return, end % Wind outward from the center. Use fixed i and increasing j, % then fixed j and increasing i, then fixed i and decreasing j, % then fixed j and decreasing i. Then repeat. k = 1; % Numbering. d = 1; % Increasing or decreasing. for p = 1:n q = 1:min(p,n-1); % Note that q is a vector. j = j-d*q; k = k-q; s(i,j) = k; if (p==n), return, end j = j(p); k = k(p); i = i-d*q'; k = k-q'; s(i,j) = k; i = i(p); k = k(p); d = -d; end

second code:

function [R, S]=inspiralcrv(M,N) Y=inspiral(max([M N])); Y=Y(1:M,1:N); Y=Y(1:M*N)'; [s, I]=sort(Y); if (nargout==2) %nargout:it returns how many inputs or outputs are actually specified in the call to the function. [R,S]=meshgrid(1:N,1:M); R=R(I); S=S(I); else R=I; end; return;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!