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

Introduction to file input/output , Introduction to File Input/output (LOAD...

Introduction to File Input/output (LOAD and SAVE): In most cases, the input to a script will come from a data file which has been generated by the other source. It is also use

Write a matlab script, Consider the function: f(x) = 7 - 28x + 42x 2 ...

Consider the function: f(x) = 7 - 28x + 42x 2 - 28x 3 + 7x 4 : Write a script findPolyRoot.m to nd, as accurately as you can, the root of f(x) near x = 2. Your script mu

Phase equilibrium, Do you have expert who can solve chemical engineering th...

Do you have expert who can solve chemical engineering thermodynamics chemical equilibrium MATLAB coding?

Format function and ellipsis, The Format Function and ellipsis: The de...

The Format Function and ellipsis: The default in MATLAB is to show numbers which have decimal places with four decimal places. The format command can be used to identify the o

Refrigerant cycle, i want the MATLAB code for properties of refrigerant R13...

i want the MATLAB code for properties of refrigerant R134a, Pentane and VCR Refrigeration cycle. Thanks

Enciphering by a shift method, Hello! How to cipher on Matlab the message c...

Hello! How to cipher on Matlab the message consisting eight symbols. At first the message shares on blocks. Then in each of blocks shift of symbols is carried out. The initial text

Illustration of built-in functions and help , Illustration of Built-in func...

Illustration of Built-in functions and help: To find out what a specific function does and how to call it, type help and then the name of function. Illustration: >> help si

Introduction to matlab, Introduction to Matlab: The MATLAB is a graphi...

Introduction to Matlab: The MATLAB is a graphical and mathematical software package; it has graphical, numerical and programming capabilities. It has built-in functions to do

Matrix inverse, how to find matrix inverse using matlab command

how to find matrix inverse using matlab command

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