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

1 回表示 (過去 30 日間)
Kenton Brown
Kenton Brown 2020 年 2 月 10 日
コメント済み: John D'Errico 2020 年 2 月 12 日
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 件のコメント
Walter Roberson
Walter Roberson 2020 年 2 月 10 日
編集済み: Walter Roberson 2020 年 2 月 10 日
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 2020 年 2 月 11 日
I'm not sure I'm understanding this. Everytime i input this, I'm getting a 'Error using sin; not enough input arguments'.

サインインしてコメントする。

採用された回答

John D'Errico
John D'Errico 2020 年 2 月 11 日
編集済み: John D'Errico 2020 年 2 月 11 日
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 件のコメント
Walter Roberson
Walter Roberson 2020 年 2 月 12 日
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 2020 年 2 月 12 日
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.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by