简体   繁体   中英

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?

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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