简体   繁体   中英

Matlab, scatter plot

I have two vectors of real values and estimated values with the same length. I want to see dependence between 2 variables. It seems scatter plot is suitable for this purpose. So, I have two questions:

  1. What is the best method to represent the dependence between my vectors?
  2. How to find the trend line or the best fit line?

I use scatter(A,B) but how to find the trend line or the best fit line?

Thanks.

散点图

The best way to compare two different groups is using analysis of variance . Analysis of variance (ANOVA) is a collection of statistical models used to analyze the differences between group means and their associated procedures (such as "variation" among and between groups). You should use ANOVA. also there are some functions included in MATLAB like: anova1, ...

p = anova1(X,group)

The standard ANOVA table divides the variability of the data into two parts:

1- Variability due to the differences among the column means (variability between groups) 2- Variability due to the differences between the data in each column and the column mean (variability within groups)

Example 1 (from mathworks) Create X with columns that are constants plus random normal disturbances with mean zero and standard deviation one:

X = meshgrid(1:5)
X =
   1   2   3   4   5
   1   2   3   4   5
   1   2   3   4   5
   1   2   3   4   5
   1   2   3   4   5

X = X + normrnd(0,1,5,5)
X =
    1.3550    2.0662    2.4688    5.9447    5.4897
    2.0693    1.7611    1.4864    4.8826    6.3222
    2.1919    0.7276    3.1905    4.8768    4.6841
    2.7620    1.8179    3.9506    4.4678    4.9291
   -0.3626    1.1685    3.5742    2.1945    5.9465

Perform one-way ANOVA:

p = anova1(X)
p =
  7.9370e-006

You can see the anova table:

在此输入图像描述

and also a box-plot related to the analysis:

在此输入图像描述

There are of course more function in MATLAB that you can check.

Actually I don't get the meaning of your image, you can easily add the line after plotting the scatter. using 'hold on' command.

Check these links for more information and examples. link - 1 link - 2 link - 3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM