简体   繁体   English

在间隔中绘制函数

[英]Plotting function in interval

I have the following function : 我有以下功能:

ySol2=(2*(x^3 + 1)^(1/2))/cos(x) +2/cos(x)

my question is how can I draw it in the interval 1000;5000 with the constrains cos(x) != 0 and x> -1? 我的问题是如何在区间1000; 5000中使用约束cos(x)!= 0和x> -1绘制它?

Something like this perhaps? 也许这样的事情?

% your function. Note element-wise operations (.^, ./)
ySol2 = @(x) (2*(x.^3 + 1).^(1/2))./cos(x) +2./cos(x);
% your x interval, with step 0.1. Note also that the argument for 'cos' is in [rad].  
x = 1000:0.1:5000;
% calculate function values
y = ySol2(x);
% keep only non-constrained values
ind = (cos(x)~=0) | (x>-1);
x = x(ind);
y = y(ind);
% plot
figure;
plot(x,y);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM