필터 지우기
필터 지우기

Not enough input arguments: how do i solve?

조회 수: 1 (최근 30일)
Ethan McCamant
Ethan McCamant 2012년 10월 19일
I am receiving the following error message:
EDU>> write2file
Error using write2file (line 8)
Not enough input arguments.
in this code:
function [] = write2file(maxLevel,avgMonths,minLevel,over_average)
fileNAME = 'ethanMcCamant.txt';
month= 1:12;
[fID,msg] = fopen(fileNAME, 'w');
if fID <0
disp(msg)
else
table = [month;maxLevel;avgMonths;minLevel;over_average];
fprintf(fID,'%g %.2f %.2f %.2 %g',table');
end
end
here is the rest of the code where I identify the variables and call in the function:
%Ethan McCamant
%Lab06.m
%10/16/12
%I worked on this assignment alone using the course material
%Program uses user defined functions to write in values from
%lake_powell.txt and then manipulates the values to provide different forms
%of output
clc, clear all
%***PROBLEM CONSTANTS***
MONTH = 12;
FIRSTYEAR = 1;
LASTYEAR = 8;
%***PROBLEM INPUTS***
%Part A
lake_powell = getWaterLevels();
%***PROBLEM OUTPUTS***
month= 1 : MONTH;
year = FIRSTYEAR : LASTYEAR;
maxLevel = zeros(FIRSTYEAR,MONTH);
avgMonths = zeros(FIRSTYEAR,MONTH);
minLevel = zeros(FIRSTYEAR,MONTH);
%Part B
%find the maximum level over the 8 year period for each month
for m = 1:MONTH
maxLevel(m)= max(lake_powell(m)');
%compute the average water level of each month over the 8 year period
avgMonths(m)= mean(lake_powell(m,:));
%find the minimum level over the 8 year period
minLevel(m)= min(lake_powell(m,:));
%compute the overall average
overall_avg = mean(lake_powell(:));
%Part C
%find how many years of each month the water level was greater than the
%overall average
over_average(m)= length(find(lake_powell(m,:) > overall_avg));
end
%Part D
write2file(maxLevel,avgMonths,minLevel,over_average);
%Part E
figure(1)
plot(month,maxLevel,'-gd',month,avgMonths,'--r^',month,minLevel,'-.b<','MarkerFaceColor','k');
title('Maximum Water Level, Average Water Level, and Minimum Water Level by Month');
xlabel('Month');
ylabel('Water Level(in feet)');
[a,b]=max(maxLevel);
textString = sprintf('The maximum water level is %.2f in month #%g',a,b);
text(2,max(maxLevel)+10,textString)
grid on
leg1 = legend('max level','avg months','min level');
set(leg1,'Location','EastOutside')
can anyone help? it will be very much appreciated
  댓글 수: 1
Walter Roberson
Walter Roberson 2012년 10월 19일
Which line of your write2file() function is line 8? The complaint is that some function you are calling inside write2file() does not have enough input arguments.

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

답변 (1개)

Sachin Ganjare
Sachin Ganjare 2012년 10월 19일
Probabably few arguments to your function Write2file(maxLevel,avgMonths,minLevel,over_average) are missing or not defined
Check the prototype of Write2file function.
Hope it helps!!
  댓글 수: 1
Ethan McCamant
Ethan McCamant 2012년 10월 19일
how would i check the prototype of the function since it is user defined?

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

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by