Can someone help me solve this. I am trying to evaluate the integral.

1 visualización (últimos 30 días)
I am trying to solve the following: Integral (sin^3*(x)/cos*(x)) dx
If anyone could help me solve this in Matlab, that would be great!
  2 comentarios
Walter Roberson
Walter Roberson el 10 de Feb. de 2020
Editada: Walter Roberson el 10 de Feb. de 2020
Hint:
Function^3(parameter)
is written as
Function(parameter).^3
Hint: that kind of division is written as ./ instead of as /
Kenton Brown
Kenton Brown el 11 de Feb. de 2020
I'm not sure I'm understanding this. Everytime i input this, I'm getting a 'Error using sin; not enough input arguments'.

Iniciar sesión para comentar.

Respuesta aceptada

John D'Errico
John D'Errico el 11 de Feb. de 2020
Editada: John D'Errico el 11 de Feb. de 2020
You don't understand. Just because a sometimes useful mathematical way of writing the cube of a function like sin, is to write it as sin^3, does not mean that is valid MATLAB syntax!!!!! Worse, you seem to be writing it s sin^3*(x), which is completely meaningless as syntax.
If you wish to compute that cube of a function like sin, use sin(x).^3, NOT sin^3(x) or sin^3*(x), neither of which is valid.
Computers are simple things. They use syntax, which if you don't follow it, they don't try to guess what you might have intended.
  3 comentarios
Walter Roberson
Walter Roberson el 12 de Feb. de 2020
Unfortunately it turns out that "Mathematical Notation" can rely on very subtle clues, and it can be ambiguous... that and some common symbols have different meanings in different contexts.
MATLAB is not good on ambiguity so it cannot use mathematical notation on input.
John D'Errico
John D'Errico el 12 de Feb. de 2020
I think the problem is that using a tool like MATLAB can often be so close to writing mathematatics on paper, that sometimes we forget the distinction. We just assume that what we write on paper will automatically translate into valid code, and that the computer will be able to know what we mean by whatever jargon we tend to use. Much of the time this surprisingly works, especially as we get started using the software. So it can be just assumed that anything goes.
For example, perhaps one of the most common syntactical errors that newer users seem to make is seen here:
a = 1;
b = 5;
x = 0:2:10
x =
0 2 4 6 8 10
a < x < b
ans =
1×6 logical array
1 1 1 1 1 1
That is, it is fairly common pencil and paper syntax to write a<x<b as jargon for the pair of tests (a<x) and (x<b). But of course, MATLAB gets this wrong, as it must. What we need to do is expand the syntactical shorthand into these components:
(a < x) & (x < b)
ans =
1×6 logical array
0 1 1 0 0 0
Now MATLAB gets it correct.
MATLAB is a language, and essentially never your first language. Learning a second language means you need to learn the syntax, just as you would if you wanted to learn to speak German, Chinese or Latin, when your first language was something else.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by