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

 채택된 답변

Roger Stafford
Roger Stafford 2014년 10월 12일

1 개 추천

The third argument in 'linspace' is interpreted as the number of desired points, so you will get at most one point in each one. It is not the same as the colon operator. See
http://www.mathworks.com/help/matlab/ref/linspace.html

추가 답변 (1개)

Image Analyst
Image Analyst 2014년 10월 12일

0 개 추천

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에 대해 자세히 알아보기

질문:

2014년 10월 12일

답변:

2014년 10월 12일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by