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

To change a variable, To change a variable: To change a variable, the ...

To change a variable: To change a variable, the other assignment statement can be used that assigns the value of a different expression to it. Consider, for illustration, the

Rules for variable names, Rules for variable names: In addition, the v...

Rules for variable names: In addition, the variable names must always be mnemonic that means they should make some sense. For illustration, if the variable is storing the radi

Function [x, please show me how this is coded in MATLAB

please show me how this is coded in MATLAB

Advection-diffusion, You are to submit your completed MATLAB code and a sho...

You are to submit your completed MATLAB code and a short written report through the Blackboard upload facility as a single zip ?le. This zip ?le should consist of your ?nite volume

Calculate power system blockset model, For the 66kV subtransmission network...

For the 66kV subtransmission network shown below, calculate the following, using a MATLAB Simulink Power System Blockset model: 1. Three phase, phase-to-phase and phase-to-earth

Simulation of a pn junction, would you please send the programing code simu...

would you please send the programing code simulation.

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