Fortran programming, Programming Languages

Assignment Help:

Question 1- In engineering applications it is often necessary to fit a straight line to a set of N points with known coordinates (xi, yi), where i indexes the points (N in total). Under certain assumptions, the equation of the line-of-best-fit through N points that also passes through the origin is given by

1468_equation 11.png

where k is the slope of the line.

Write a subroutine (find_k) that receives the coordinates of N points from a calling program and calculates/returns the coefficient k in the best-fit equation through the origin. The size N of the arrays should be supplied to the subroutine as a separate integer argument.

Test your subroutine by computing the coefficient k for the line that best fits the following points:

2176_table xy.png

The data should be read from a data file named "points.dat" in the main program. The first line of the file should contain the number of points to be read. The following lines should contain pairs of numbers describing the coordinates of N points (one pair per line).

The arrays (array) storing the coordinates should allocatable. The program should output the value of k computed by the subroutine to the screen, using formatted output with 3 decimal places. Prepare a short report plotting the points and the line of best fit (either using Excel, or any other graphics program). Report the value of k used.

Question 2- A point in a rank-2 array is said to be a relative maximum if it is higher than any of the 8 points surrounding it. For example, the element at position (2,2) in the array shown below is a relative maximum, since it is larger than any of the surrounding points.

2045_matrix 1.png

Write a program to read a matrix A from an input file, and to scan for all relative maxima within the matrix. The first line in the file should contain the number of rows (m) and the number of columns (n) in the matrix, and then the next lines should contain the values in the matrix, with all of the values in a given row on a single line of the input file. Use an allocatable array for matrix A. The program should only consider interior points within the matrix, since any point along an edge of the matrix cannot be completely surrounded by 8 points. Your program must output all relative maxima and their locations (number of the row and number of the column where the relative maximum is located) on the screen. Test your program by finding all of the relative maxima of the following matrix, print/report the results.

804_long matrix.png


Related Discussions:- Fortran programming

Cookies management with perl, One of the main strengths of the Perl program...

One of the main strengths of the Perl programming language are its powerful text manipulation features. In this assignment, you will put them to use for writing a Perl program tha

C++ programing, how to rewrite C++ program the DNAStrand class (DNA Project...

how to rewrite C++ program the DNAStrand class (DNA Project) to instead store the nucleotide sequence in a dynamically-allocated array?

.net class libraries in .net, .NET class libraries in .NET Whether you c...

.NET class libraries in .NET Whether you create value in C# or VB.NET, you are getting in touch with techniques in the same .NET category your local library. The same .NET str

What is the switch statement, What is the switch Statement? This is a dif...

What is the switch Statement? This is a different form of the multi way decision that It is well structured, but can only be used in certain cases where: 1. Here, Only one var

Write and test a simple perl program on the linux platform, Write and test ...

Write and test a simple perl program on the linux platform.  You may use any linux system you wish, including the Suse linux installed in the lab. Activities. Note:  to r

Matlab fem, I need a program that writes the first column of the matrix. T...

I need a program that writes the first column of the matrix. The numbers in this column follow the pattern below: 1. Numbers start at 1 and count up to ''nels'' in increments of

C language code, Go to the following link and please do Problem 6. This is ...

Go to the following link and please do Problem 6. This is in C language. http://wikisend.com/download/304748/hw%206.pdf The code I need must be in C language and not C++ . Thank

Java, Write a program that repeatedly prompts for and reads a positive inte...

Write a program that repeatedly prompts for and reads a positive integer value n and then calculates and displays the nth Fibonacci number

Write c sharp application to read a data, A number of simple student record...

A number of simple student records are written to a text file. The format of some typical linesshould be - Task (1): Using a text editor, create a file with 10 such reco

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