Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Joe Celkos Data And Databases Concepts In Practice

Authors: Joe Celko

1st Edition

1558604324, 978-1558604322

More Books

Students also viewed these Databases questions

Question

1. Discuss the four components of language.

Answered: 1 week ago

Question

a. How many different groups were represented?

Answered: 1 week ago