Fortran programming, Programming Languages

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

Posted Date: 2/25/2013 5:59:58 AM | Location : United States

Related Discussions:- Fortran programming, Assignment Help, Ask Question on Fortran programming, Get Answer, Expert's Help, Fortran programming Discussions

Write discussion on Fortran programming
Your posts are moderated
Related Questions
A string s is said to be periodic with a period α, if s is α k for some k > 2. (Note that α k is the string formed by concatenating k times.) A DNA sequence s is called a tande

Question 1 How to call a WML Script from a WML Page? Question 2 Write short notes on WML Script Operators and Expressions Question 3 Write short notes on WML Script Statements

2. TEST & AND TEST is like CMP, it is used for conditional statement, and doesn’t save the answer. AND is logical multiplication. 3. INS & IN IN is used for data transfer from I/O

Memory Hierarchy for Linux Systems A cache line has one or more valid bit(s), tag entry and list of bytes in a block in one set of a cache, as shown below: If you were

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

This assignment is divided into two parts. The goal is to write a Java program that calculates capital gain on a stock market, see Lab 7. When a share of common stock of some co

Question 1 Explain the history of Internet Question 2 What are the advantages of DHTML? Question 3 Explain the concept of DOM Question 4 How does AJAX work

The idea of this section is not to do anything new along with a series solution problem.  Instead this is here to exemplify that moving in a higher order differential equation does

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