matlab y = 1/√x图像和y = 1/x图像
y = 1/√x与y = 1/x
clc, clear, close all;
length = 3;
axis_len = 5;% Create a range of x values
x = linspace(0.01, length^2, 1000); % Avoid x = 0 for 1/√x% Compute the corresponding y values
y1 = 1 ./ sqrt(x);
y2 = 1 ./ x;
% Plot the graph
plot(x, y1, 'r', 'LineWidth', 1);
hold on;
plot(x, y2, 'g', 'LineWidth', 1);
xlabel('x');
ylabel('y');
title('y = 1/√x图像和y = 1/x图像');
grid on;
legend('y = 1/√x', 'y = 1/x');
xlim([-axis_len,axis_len]);
ylim([-axis_len,axis_len]);
绘制结果
y=√x
clc, clear, close all;
length = 3;
axis_len = 5;% Create a range of x values
x = linspace(0.01, length^2, 1000); % Avoid x = 0 for 1/√x% Compute the corresponding y values
y1 = 1 ./ sqrt(x);
y2 = 1 ./ x;
y3 = sqrt(x);
% Plot the graph
plot(x, y1, 'r', 'LineWidth', 1);
hold on;
plot(x, y2, 'g', 'LineWidth', 1);
hold on;
plot(x, y3, 'b', 'LineWidth', 1);
xlabel('x');
ylabel('y');
title('函数图像');
grid on;
legend('y = 1/√x', 'y = 1/x','y = √x');
xlim([-axis_len,axis_len]);
ylim([-axis_len,axis_len]);