Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

QUAD function request a user input

1 Ansicht (letzte 30 Tage)
Kyle Taliaferro
Kyle Taliaferro am 14 Feb. 2013
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
i have a this function:
x.^2 .*sin(sqrt(x)-10)+A
I need to use the QUAD function to solve for it, but how do i request the user to input what A is and still allow the QUAD function to work. I have been trying to use "inline" to create the function. Also how do i allow the user to input what delta X equals. Here is the code i have so far;
% This program will call the matlab function QUAD to solve the function:
%Y=X^2sin(SQRT(X)-10)+A
% A will be inputed from the user along with delta X
clear all, clc
A=input('Please enter a number for A ')
f(A)=inline('x.^2 .*sin(sqrt(x)-10)+A')
Answer=quad(f,1,5,.10)
  1 Kommentar
Walter Roberson
Walter Roberson am 14 Feb. 2013
Do not use "clear all" in your code.

Antworten (1)

Walter Roberson
Walter Roberson am 14 Feb. 2013
Use anonymous functions instead of inline functions. And do not try to store the function into f(A)
f = @(x) x.^2 .* sin(sqrt(x)-10) + A;

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by