Example code in matlab programming, MATLAB Programming

Assignment Help:

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')


Related Discussions:- Example code in matlab programming

Write a matlab function, There are many approaches to numerically estimatin...

There are many approaches to numerically estimating the derivative of the function.  The relationship:   is called a forward difference, since the estimate of the derivativ

Plot the input and the output of the filter on a single plot, An FIR filter...

An FIR filter has coefficients b = [ 1.0000   -0.6387    1.0214    0.8210   -0.7470    1.0920 ] (a) Find H(z) for the filter and plot its frequency response (magnitude and phase

Null basis and range basis, You will write functions • B=null basis(A,tol);...

You will write functions • B=null basis(A,tol); • B=range basis(A,tol); The function null basis takes a matrix A as input, and outputs a basis for the null space of A, obtained via

Format command, Format command: The format command can be used to cont...

Format command: The format command can be used to control the spacing between the MATLAB command or expression and the outcome; it can be either compact or loose. >> format

Simple related plot functions, Simple Related Plot Functions: The othe...

Simple Related Plot Functions: The other functions which are useful in customizing plots are the figure, clf, hold, leg-end, and grid. The short description of such functions

Expert system, how can i write a programm about maze solver expert system o...

how can i write a programm about maze solver expert system only with if & then

Calculate sample mean and standard deviation, Make a vector of 500 random n...

Make a vector of 500 random numbers from a normal distribution with mean 2 and standard deviation 5(randn). a After you generate the vector, verify that the sample mean and stan

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd