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

Transportation problem, I want codding in matlab for vogel approximation me...

I want codding in matlab for vogel approximation method . i mean .M file for vogels approximation method.

Midpoint circle, drow midpoint circle for scan converting acircle in matlab...

drow midpoint circle for scan converting acircle in matlab

Generate two waveforms-analog waveform, The purpose of this lab is to intro...

The purpose of this lab is to introduce students to the basic concept of overtones. In order to generate two tones at the same time, you need to generate two waveforms and add them

Geotifwrite, why after i crop part of a tiff image the cropped image is of...

why after i crop part of a tiff image the cropped image is of different pixel resolution

Calculate the bandwidth of this filter matlab, The purpose of this lab is ...

The purpose of this lab is to enhance the ECE311 student's understanding of filter behavior and filter design and to provide the student the opportunity to demonstrate skills in li

ANFIS, how to design a digital fir filter using anfis in matlab.get the cod...

how to design a digital fir filter using anfis in matlab.get the code for that.

Write a for loop to perform elementary row operations, Use Matlab to solve ...

Use Matlab to solve the following set of linear equations by Gaussian Elimination. Write a for loop to perform elementary row operations on the augmented matrix to produce

Matlab function to find and plot the dft, It is desired to determine the DF...

It is desired to determine the DFT of the analogue signal x (t) = 25 cos(10 Πt)cos(400Πt). (a) Find the Nyquist rate of the signal.   (b) What is the record (signal) length i

Appending data to a data file, Appending data to a data File: A text f...

Appending data to a data File: A text file once exists; the data can be appended to it. The format is similar as formerly, with the addition of the qualifier -append. For illu

Convolution, Perform the convolution of following sequences (a) x[n] = [1 2...

Perform the convolution of following sequences (a) x[n] = [1 2 3], N1 = 1 and h[n] = [1 - 1], N2 = 1 (b) x[n] = [1 2 3], N1 = 2 and h[n] = [1 - 1], N2 = 1 (c) x[n] = [1 2 3], N1 =

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