In Matlab - how do I plot the limit when x reaches 0 in the function (x - sqrt(x)) / sqrt(sin(x)) ?
I've just started programming, so I'm very new to this.
I've been trying to plot the function in various ways, one of which is:
y = @(x) (x - sqrt.(x))./ (sqrt.(sin.*x));
fplot(y,[0.1 0.9], 200)
Which gives the following error code: Argument to dynamic structure reference must evaluate to a valid field name.
I've also tried without the function handle, like this:
x = linspace(0.1, pi/2, 200);
y = (x - sqrt.(x))./ (sqrt.(sin.*x));
plot(x, y)
Which gives the same error code as the previous one. I've tried without the dots, tried with different intervals and I don't understand the error code.
The bounds/range of the plot can be changed by adjusting X_Min, X_Max, Y_Min and Y_Max
as you'd like.
y = @(x) (x - sqrt(x))./(sqrt(sin(x)));
X_Min = -5;
X_Max = 20;
Y_Min = -100;
Y_Max = 100;
fplot(y,[X_Min X_Max]);
axis([X_Min X_Max Y_Min Y_Max]);
This method depends highly on the plotting interval/density. Unfortunately, this method does not show dotted lines on the limits unlike method 1.
X_Min = -5;
X_Max = 20;
Y_Min = 0;
Y_Max = 100;
Plotting_Density = 1000;
x = linspace(X_Min, X_Max, Plotting_Density);
y = (x - sqrt(x))./(sqrt(sin(x)));
plot(x, y);
axis([X_Min X_Max Y_Min Y_Max]);
The use of the .
implies elemental operations. Using . will apply the function to all the elements of an array. In this case, it is not necessary to use the .
operation since the term x is used in an anonymous function.
• "./" -> Division over all elements in array
• ".*" -> Multiplication over all elements in array
Using MATLAB version: R2019b