Trying to plot a function

2 次查看(过去 30 天)
Evan Gehret
Evan Gehret 2023-12-14
评论: Dyuman Joshi 2023-12-15
I am trying to plot the following function and have the period after "theta_shock", but I am getting an error of "Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters"
theta_shock = 0:90
M = 2
g = 1.4
half_cone = atand((M^2*sind(theta_shock.)-1)/(M^2*(g+cosd(2*theta_shock.))+2))
plot(theta_shock,half_cone)
What am I doing wrong and how do I fix this?

回答(1 个)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023-12-14
Here is the fixed code:
theta_shock = 0:90;
M = 2;
g = 1.4;
half_cone = atand((M^2*sind(theta_shock)-1)./(M^2*(g+cosd(2*theta_shock))+2));
plot(theta_shock,half_cone)
  1 个评论
Dyuman Joshi
Dyuman Joshi 2023-12-15
The source of the error were the fullstops present after theta_shock
Removing them and using the element-wise division for numerator and denominator gave the correct output.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by