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
Example of Hold and legend function: Running this script will generate two individual figure windows. If there is not any other active figure window, the first, that is the ba

1. Design a suitable phase-lead controller. You should explain in detail how your design has been developed. Your solution should include Bode plots constructed both manually and

Expand a matrix: To expand a matrix, an individual element could not be added as that would mean there would no longer be the similar number of values in every row. Though,

This problem is intended to demonstrate some problems that can arise from the finite precision of numerical calculations performed with computers.  We will do this by approximating

I need assignment to finish.

Write a MATLAB program (using/making the necessary functions that you deem necessary) that does the two following jobs: It generates the following digital modulation schemes. In

Write a MATLAB program to find the undamped natural frequencies and modes of an electric car treating it as a four degree of freedom system. Determine the undamped natural frequenc

How do you write a programme that asks the user for a number between 1 and 1000 and calculates the sum of its digits?

Create MATLAB program(s) that solve a problem of your own choice. You may opt to solve work related problem, an industrial problem, or problem from your research project. Markin

From A to B the inlet valve is open and the steam pressure increases linearly from 0.1000 MPa absolute to 15.00 MPa absolute, 1000°C. The inlet valve closes and from B to C the