Hey all, i really need some help at the moment, as i keep getting the error message
??? Error using ==> answerassignmentq3
Too many input arguments.
Error in ==> errq3assignment at 11
integral = answerassignmentq3(1500);
I am using the function as shown below and have pretty much hit a brick wall with what to do now. Any help would be greatly appreciated. Below the function below i will show you the question i am trying to solve. Many Thanks.
function errq3assignment
clc
% exact_ans=trapez(15000);
% for i=1:15000
% approx_ans=trapez(i);
% error=abs((exact_ans-approx_ans)/exact_ans)
% if error<=0.001
% break
% end
% end
integral = answerassignmentq3(1500);
trial_integral = 0;
N = 100;
while 1
trial_integral = answerassignmentq3(N);
if abs((trial_integral-integral)/integral) < 0.001
break;
end
N=N+1;
end
disp(N);
disp(integral);
disp(trial_integral);
end
The energy E stored in the spring, at equilibrium, may be expressed in the form
E =
∫ d
0
F(x)dx
Use the composite trapezoidal rule to obtain an approximation to the value of E, with a relative
error of less than 0:001%.
Note the 6 digits uvwxyz of your student number. You should then use the parameter values
k1 = 45000 (1+u) k2 = 8100 (1+v) m = 960 (1:2 􀀀 0:1 w)
h = 0:43 (1+0:1 x) g = 9:8 (1+0:01 y)
a = 1+0:01 z b = 1:5+0:01 u
To illustrated the process of creating the problem data, suppose your student number is 970254. In this case, u = 9,
v = 7, w = 0, x = 2, y = 5 and z = 4. Your solution should then be for the parameter values
k1 = 450000 k2 = 64800 m = 1152 g = 10:29
h = 0:516 a = 1:04 b = 1:59
4
|
|
0
|
|
|
|
Reply
|
luke
|
12/9/2010 4:15:06 PM |
|
luke baldwin wrote:
> Hey all, i really need some help at the moment, as i keep getting the
> error message
> ??? Error using ==> answerassignmentq3
> Too many input arguments.
>
> Error in ==> errq3assignment at 11
> integral = answerassignmentq3(1500);
>
> I am using the function as shown below and have pretty much hit a brick
> wall with what to do now. Any help would be greatly appreciated. Below
> the function below i will show you the question i am trying to solve.
> Many Thanks.
>
>
>
> function errq3assignment
....
Well, the function definition doesn't accept _any_ arguments, so when
you try to call it with one, it's not surprising Matlab complains.
Got to fix either the function definition to accept a value if you want
it to do so or else don't try to call it with a value if it doesn't
allow same....all in all, pretty sraightforward it would seem.
--
|
|
0
|
|
|
|
Reply
|
dpb
|
12/9/2010 4:23:01 PM
|
|
On 09/12/10 10:15 AM, luke baldwin wrote:
> Hey all, i really need some help at the moment, as i keep getting the
> error message
> ??? Error using ==> answerassignmentq3
> Too many input arguments.
>
> Error in ==> errq3assignment at 11
> integral = answerassignmentq3(1500);
We don't know, as you have not shown us the code for answerassignmentq3 .
|
|
0
|
|
|
|
Reply
|
Walter
|
12/9/2010 5:02:41 PM
|
|
Walter Roberson <roberson@hushmail.com> wrote in message <RY7Mo.6764$KT3.5241@newsfe08.iad>...
> On 09/12/10 10:15 AM, luke baldwin wrote:
> > Hey all, i really need some help at the moment, as i keep getting the
> > error message
> > ??? Error using ==> answerassignmentq3
> > Too many input arguments.
> >
> > Error in ==> errq3assignment at 11
> > integral = answerassignmentq3(1500);
>
> We don't know, as you have not shown us the code for answerassignmentq3 .
The codeis shown at the top as it is with the % signs before it
|
|
0
|
|
|
|
Reply
|
luke
|
12/9/2010 5:58:05 PM
|
|
"luke baldwin" <487605@swansea.ac.uk> wrote in message <idr5bd$n2a$1@fred.mathworks.com>...
> Walter Roberson <roberson@hushmail.com> wrote in message <RY7Mo.6764$KT3.5241@newsfe08.iad>...
> > On 09/12/10 10:15 AM, luke baldwin wrote:
> > > Hey all, i really need some help at the moment, as i keep getting the
> > > error message
> > > ??? Error using ==> answerassignmentq3
> > > Too many input arguments.
> > >
> > > Error in ==> errq3assignment at 11
> > > integral = answerassignmentq3(1500);
> >
> > We don't know, as you have not shown us the code for answerassignmentq3 .
>
This is the code used for answerassignmentq3
% exact_ans=trapez(15000);
% for i=1:15000
% approx_ans=trapez(i);
% error=abs((exact_ans-approx_ans)/exact_ans)
% if error<=0.001
% break
% end
% end
What needs to be added or removed in order for this to work, or is the code far too problematic, i am unsure of everything as it is a code that i had used last year and wondered if it still worked.
|
|
0
|
|
|
|
Reply
|
luke
|
12/9/2010 6:09:05 PM
|
|
On 09/12/10 11:58 AM, luke baldwin wrote:
> Walter Roberson <roberson@hushmail.com> wrote in message
> <RY7Mo.6764$KT3.5241@newsfe08.iad>...
>> On 09/12/10 10:15 AM, luke baldwin wrote:
>> > Hey all, i really need some help at the moment, as i keep getting the
>> > error message
>> > ??? Error using ==> answerassignmentq3
>> > Too many input arguments.
>> >
>> > Error in ==> errq3assignment at 11
>> > integral = answerassignmentq3(1500);
>>
>> We don't know, as you have not shown us the code for answerassignmentq3 .
>
> The codeis shown at the top as it is with the % signs before it
No it isn't. The part you posted that has the % signs in front of it has
no 'function' declaration in it, so it is just random code included for
no obvious reasons. We need to see the code for the complete function
answerassignmentq3 to be able to tell you why it isn't working. We need
to see what the output arguments are on the left hand side and we need
to see what the input arguments are on the right hand side.
|
|
0
|
|
|
|
Reply
|
Walter
|
12/9/2010 6:10:04 PM
|
|
On 09/12/10 12:09 PM, luke baldwin wrote:
> This is the code used for answerassignmentq3
>
> % exact_ans=trapez(15000);
> % for i=1:15000
> % approx_ans=trapez(i);
> % error=abs((exact_ans-approx_ans)/exact_ans)
> % if error<=0.001
> % break
> % end
> % end
If that is _exactly_ what is stored in answerassignmentq3.m then when
you invoked answerassignmentq3(1500) you would get an error about
attempting to invoke a script as a function. As that is not the error
you got, we conclude that that is NOT your code for answerassignmentq3.m
|
|
0
|
|
|
|
Reply
|
Walter
|
12/9/2010 6:14:20 PM
|
|
luke baldwin wrote:
> "luke baldwin" <487605@swansea.ac.uk> wrote in message
> <idr5bd$n2a$1@fred.mathworks.com>...
>> Walter Roberson <roberson@hushmail.com> wrote in message
>> <RY7Mo.6764$KT3.5241@newsfe08.iad>...
>> > On 09/12/10 10:15 AM, luke baldwin wrote:
>> > > Hey all, i really need some help at the moment, as i keep getting the
>> > > error message
>> > > ??? Error using ==> answerassignmentq3
>> > > Too many input arguments.
>> > >
>> > > Error in ==> errq3assignment at 11
>> > > integral = answerassignmentq3(1500);
>> > > We don't know, as you have not shown us the code for
>> answerassignmentq3 .
>>
> This is the code used for answerassignmentq3
>
> % exact_ans=trapez(15000);
....
> % end
>
> What needs to be added or removed in order for this to work, or is the
> code far too problematic, i am unsure of everything as it is a code that
> i had used last year and wondered if it still worked.
Well, it couldn't have ever worked--as Walter says, it isn't a function
at all and there's nothing to execute, anyway, even if it were.
I did look too quickly initially and made an error in that the function
shown wasn't the one that had the error--however, one would presume from
the error message that what you really have is another function of the
same form--ie, one not expecting any input arguments.
But, as Walter says, until a complete and functional and self-consistent
set of code is posted, it's the crystal ball talking, not analysis...
--
|
|
0
|
|
|
|
Reply
|
dpb
|
12/9/2010 6:24:01 PM
|
|
many thanks, all sorted i have found my other file and now all works fine.
Walter Roberson <roberson@hushmail.com> wrote in message <109Mo.1430$3l4.634@newsfe04.iad>...
> On 09/12/10 12:09 PM, luke baldwin wrote:
>
> > This is the code used for answerassignmentq3
> >
> > % exact_ans=trapez(15000);
> > % for i=1:15000
> > % approx_ans=trapez(i);
> > % error=abs((exact_ans-approx_ans)/exact_ans)
> > % if error<=0.001
> > % break
> > % end
> > % end
>
> If that is _exactly_ what is stored in answerassignmentq3.m then when
> you invoked answerassignmentq3(1500) you would get an error about
> attempting to invoke a script as a function. As that is not the error
> you got, we conclude that that is NOT your code for answerassignmentq3.m
|
|
0
|
|
|
|
Reply
|
luke
|
12/9/2010 6:26:04 PM
|
|
|
8 Replies
334 Views
(page loaded in 0.065 seconds)
|