Problem on Vectors

Create a vector representing x coordinates of a measurement with 20 points between 0 and 10. Create another vector y representing fake measurements which are related to the above x values as y = 2.3 x – 1.2. Next add random (normal, Gaussian) noise to the vector y. Plot on the same graph both versions of vector y in different colors. Next use attached linregr.m function to find a least square fit (linear regression) for your fake experimental data.

E

Expert

Verified

Calculations:

x=0:0.5:10;

y = 2.3*x - 1.2;

x1=x.^2;

xvar=mean(x1)-((mean(x)).^2);

xstd=sqrt(xvar);

noise= 1/(sqrt(2*pi*xstd))*exp(-((x-mean(x)).^2)/(2*xvar));

y1=y+noise

plot(x,y,x,y1,'g');

legend('Normal Y vector','Noise additive Y vector');

XLABEL('x')

YLABEL('Normal Y vector=2.3*x-1.2')

[a, r2]= linregr(x,y);


Results:

502_2013a.jpg


Least square fit Results gives the Least regression for the fake experimental results a = vector of slope, a(1)- → 2.3, and intercept a(2)-→ -1.2
r2 = coefficient of determination = 1

 

2061_2013b.jpg

   Related Questions in Programming Languages

  • Q : Define the term Graphical User Interface

    Graphical User Interface: A Graphical User Interface (abbreviated as GUI) is a part of a program which permits user interaction through graphical components, like menus, buttons, text areas, and so forth. Interaction frequently includes the usage of a

  • Q : Explain Java Virtual Machine Java

    Java Virtual Machine (JVM): It is an idealized machine whose instruction set comprises of bytecodes. Java program is compiled to an equal bytecode form and performed on an interpreter that implements the JVM.

  • Q : Explain the way to enter element content

    Explain the way to enter element content.

  • Q : Define Micro-Controller Define

    Define Micro-Controller.

  • Q : Illustrates the difference between

    Illustrates the difference between Property Get, Let and Set?

  • Q : Define the term XML Canonicalization

    Define the term XML Canonicalization?

  • Q : What is Hash code Hash code : It is a

    Hash code: It is a value returned by a hash function. A hash code can be employed as an index into a random-access data structure, offering a proficient mapping between an object and its position. Employed by classes like HashMap.

  • Q : Explain Hot spot Hot spot : This is an

    Hot spot: This is an area in an image map with a specific significance. A program usually monitors movements of the mouse, and reacts according to the actions related with the hot spots over which it passes. This may comprise displaying various status

  • Q : Input and output formatting in C++

    Input output formatting in C++: C++ support

  • Q : Reading Algorithms Assignment 1:

    Assignment 1: Algorithms Rules: See the Assignment Rules file on the class Moodle site. 1 Reading Algorithms (20 points) Input: A nonempty string of characters S1S2 . . . Sn, and a positive integer n giving the number of characters in the string. Output: See t

©TutorsGlobe All rights reserved 2022-2023.