I'm attempting to satisfy an equation using 10 random numbers in the range [-pi,pi]. The results tend to be in an odd format and only one of the values ever seems to match, suggesting that something is going wrong. My attempt is below, any help would be apprectiated :).
x = (rand(10,1) * 2 - 1) * pi
y1 = (3*cot(x)-(cot(x).^3))/(1 - 3*(cot(x).^2))
y2 = cot(3*x)
y1 =
Columns 1 through 7
0 0 0.0047 0 0 0 0
0 0 -0.0395 0 0 0 0
0 0 -2.6571 0 0 0 0
0 0 0.0034 0 0 0 0
0 0 0.0047 0 0 0 0
0 0 0.0082 0 0 0 0
0 0 -0.0068 0 0 0 0
0 0 0.0095 0 0 0 0
0 0 -0.0573 0 0 0 0
0 0 0.1041 0 0 0 0
Columns 8 through 10
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
y2 =
-1.4220
-0.4570
-2.6571
-0.8258
-1.4221
0.4081
-0.2741
0.7070
-0.5596
0.7511
Granted the values change each time, it seems that one always seems to work and I'm not entirely sure why.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2019년 6월 19일

댓글:

2019년 6월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by