Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8718879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:39:25+00:00 2026-06-13T06:39:25+00:00

I encounter a strange problem with quad function. I was using quad to calculate

  • 0

I encounter a strange problem with quad function.
I was using quad to calculate simple integral, and it worked for 10 to 20 times, then Matlab issues the following error:

Error using quad (line 75)
The integrand function must return an output vector of the same length as the input vector. 
yteor(k) = quad(@(q)(exp(-(q).^2).*q.^2/(k.^2+1)), 0, 1);

Here q and k are scalars.
I can not get what is wrong and why it worked several hours ago.

Edit

Here is my code

for k=1:100,
    xteor(k)=step*k;
    yteor(k)=quad(@(q)(exp(-(q).^2).*q.^2/((step.*k+1).^2)),0,1);
end plot(xteor,yteor,'r');
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:39:26+00:00Added an answer on June 13, 2026 at 6:39 am

    The following snippet works for me on Octave (Matlab GNU clone)

    step = 1;
    xteor = zeros(100,1);
    yteor = zeros(100,1);
    
    for k=1:100,
      xteor(k)=step*k;
      yteor(k)=quad(@(q)(exp(-(q).^2).*q.^2/((step.*k+1).^2)),0,1);
    end
    plot(xteor,yteor,'r');
    pause
    

    My hypothesis is that your error is the consequence of something else happening earlier in your code (maybe related to step not being a scalar?). Instead of focusing on this line where the error arise. Try to search what you have changed just before the error appear.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I encounter a strange Problem with Rails3 and send_data . A simple controller action
I'm using LINQ to NHibernate and encountered a strange problem while comparing strings. Following
I encounter a unbelievable strange problem: The libxml parser I'm using makes a difference
I just encounter a strange problem: var a:ClassA = new ClassA; var b:ClassA =
I have encountered a very strange problem in using jQuery load() . I used
Today I had a strange encounter with gcc. consider the following code: float len[ELEM+1];
I have a strange problem that i didn't encounter before i must mention that
I have just encountered a strange problem when using jQuery Mobile. I have a
I have encountered strange problem. I have created simple Flash text field control and
I encounter a strange thing while coding in Xcode 4.3. The nature of problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.