Do not understand why my code isn't working!
显示 更早的评论
it should be simple, but nothing show in the figure and nothing is reported by the debugger.
x1=linspace(0,0.1,0.49);
x2=linspace(0.51,0.1,1);
y1=1./(2*x1-1);
y2=1./(2*x2-1);
plot(x1,y1), plot(x2,y2), grid
采纳的回答
更多回答(1 个)
Image Analyst
2014-10-12
You're mixing two ways of specifying a range of variables into one single way that does not work. Here, check out my code to see the two ways. Just pick one of them:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
fontSize = 20;
% Two ways of specifying x. Pick one:
% Method 1:
x1 = 0 : 0.1 : 0.49;
x2 = 0.51 : 0.1 : 1;
% Method 2:
x1 = linspace(0, 0.1, 15);
x2 = linspace(0.51, 0.1, 300);
y1=1./(2*x1-1);
y2=1./(2*x2-1);
plot(x1,y1, 'bo-', 'LineWidth', 2)
hold on;
plot(x2,y2, 'r*-', 'LineWidth', 2);
grid on;
xlabel('X', 'FontSize', fontSize);
ylabel('Y', 'FontSize', fontSize);
title('Y1 and Y2 vs. X', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);

类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!