How to overlay a plot onto a scatter plot?

clc; clear all;
load('../data/points2D_Set1'); % gives variables x and
% y and x range is [0,1] and it's loading correctly
xtrue=[0:1e-4:1];
ytrue=1.5*x+2.5;
plot(xtrue,ytrue);
hold on;
scatter(x,y);
my aim is to overlay the plot on the scatter plot but when I run this I'm getting an empty plot

댓글 수: 2

Daniel M
Daniel M 2019년 10월 19일
I can't seem to reproduce your issue. Can you upload the data? The only thing I can think of is x or y are all the same value, or are NaN.
MOLE
MOLE 2019년 10월 19일
I just updated with the .mat file; just change the path when you use it.

댓글을 달려면 로그인하십시오.

 채택된 답변

Daniel M
Daniel M 2019년 10월 19일

0 개 추천

You cannot plot vectors of different size.
whos x y xtrue ytrue
You'll see that x and y are 300x1, xtrue is 1x10001, and ytrue is 300x1. Perhaps you mean to write
ytrue=1.5*xtrue+2.5;

댓글 수: 1

MOLE
MOLE 2019년 10월 19일
Oh, my bad. I though the problem was with the overlaying. Thanks.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Scatter Plots에 대해 자세히 알아보기

질문:

2019년 10월 19일

댓글:

2019년 10월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by