Not enough input arguments: how do i solve?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Walter Roberson
le 19 Oct 2012
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.
Réponses (1)
Sachin Ganjare
le 19 Oct 2012
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!!
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!