Example code in matlab programming, MATLAB Programming

clear

clc

%% DATA INPUT

filename = input('Enter file name, including its extension: ', 's'); D = load(filename);

%or load('Mphi.out');

%%

%Trendline

%Evaluates the polynomial c at the values in X. c is a vector of

%coefficients in descending powers.

c=polyfit(x,y,1);

yhat=polyval(c,x);

c=polyfit(x,y,2);

yhat=polyval(c,x);

c=polyfit(x,y,3);

yhat=polyval(c,x);

c=polyfit(x,y,4);

yhat=polyval(c,x);

c=polyfit(x,y,5);

yhat=polyval(c,x);

c=polyfit(x,y,6);

yhat=polyval(c,x);

c=polyfit(x,y,7);

yhat=polyval(c,x);

c=polyfit(x,y,8);

yhat=polyval(c,x);

c=polyfit(x,y,9);

yhat=polyval(c,x);

c=polyfit(x,y,10);

yhat=polyval(c,x);

c=polyfit(x,y,11);

yhat=polyval(c,x);

c=polyfit(x,y,12);

yhat=polyval(c,x);

c=polyfit(x,y,13);

yhat=polyval(c,x);

c=polyfit(x,y,14);

yhat=polyval(c,x);

c=polyfit(x,y,15);

yhat=polyval(c,x);

%Correlation coefficient

R=corrcoef(x,y);

R=R(1,2);

%Coefficient of determination

%{

mx=mean(x);

my=mean(y);

syy=sum(y.^2)-length(x)*my^2;

sse=syy-c(1)*(sum(x.*y)-length(x)*mx*my);

R2=1-sse/syy;

%}

%or

R2=R^2;

%%

%PLOT

figure(1)

plot(x,y,'o')

holdon

plot(x,yhat,'k')

title('\fontname{Arial} \bf Performance of racing motorcycles equipped with Tire-X

tires','FontSize', 12);

xlabel('Lap time [s]');

ylabel('Ambient temperature [F]');

axis([65 68 0 100])

text(65.2,90,['Coefficient of determination R^2= ' num2str(R2,3)])

text(65.2,85,['Correlation coefficient R= ' num2str(R,3)] )

legend('Data points',['Trendline y=' num2str(c(1),5) 'x' num2str(c(2),

5)],'location','best')

Posted Date: 3/15/2013 2:07:40 AM | Location : United States







Related Discussions:- Example code in matlab programming, Assignment Help, Ask Question on Example code in matlab programming, Get Answer, Expert's Help, Example code in matlab programming Discussions

Write discussion on Example code in matlab programming
Your posts are moderated
Related Questions

MATLAB. • MATLAB Programming; • Simulation in MATLAB.

Hello my name is lalitkumar and I am a student.I needed help in MATLAB for recognition of colour randomly using webcam realtime for RGB without external trigger.please mail the co

Project: "An Efficient Human Identification Using Gait Analysis" I want apply/follow the same methodology (Methods/Algorithms) for this paper ("Human Gait Recognition Using Bezi

Creating Matrix Variables: Creating a matrix variable is actually just a generalization of creating a row and column vector variables. That is, the values within the row are s

design a rc phase shift oscillator for a particular frequency of oscillation and generate a sinusoidal signal

A band pass FIR filter is required to pass frequencies from 5KHz to 8KHz, using a sample rate of 40K i) Explain how this would map to normalization sampling frequencies in radia

Answers should be submitted in an MS Word document. Simulations should accompany answers in a separate MATLAB file. 1)  Queuing Simulator: Consider a communications router that

Looping Statements: Consider the problem of computing the area of a circle with radius of 0.3 centimeters-a MATLAB program certainly is not required to do that; you would use

the basic equation of modeling radioactive decay is where the amount of the radioactive substance is at time and is the decay rate. Some radioactive substances decay into other rad