Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MATLAB Given a (plain text!) file containing N columns of values, we need to read the values into matlab for exploration and plotting. To do

MATLAB

Given a (plain text!) file containing N columns of values, we need to read the values into matlab for exploration and plotting. To do this, we need to know the name of the file, and how data is arranged in it, so need to open it in a (plain text!) editor. Write a script "read.m" which:

1.) reads a given file "file.dat" into a matrix "mat",

2.) extracts the columns from "mat" into arrays "c1", "c2", ..., "cN",

3.) plots some column versus another column, with a title, and labeled axes.

To test and debug your code, create a "file.dat" with N=2 columns, each with 3 values ( so a 32 array ). The first column should be sorted. You can just enter some numbers in "file.dat" in an editor. Next, test it on a 43 array to make sure it also works. Insert brief comments to document what is being done.

To Do:

Download the file file.dat and save it as "file.dat" . View it in an editor to see its contents. The first two lines contain labels, need to be read over with fgetl . The rest of the lines are numerical values to be scanned into a matrix, say "mat". Plot columns 1 , 3 using Gnuplot: gnuplot> plot "prof300s.dat" u 1:3 w lines lw 2 Copy your "read.m" to "lab.m" and modify appropriately to achieve the following: a. Read the data into a matrix "mat". b. Extract each column into a vector (with sensible names: x , C , B , ... ). c. Find Bmax = maximum value of B, and at which index it occurs, iBmax. Set cut = Bmax/2 . d. Plot B vs x and the line at height cut, on the same plot. The units of x are micrometers (m). Note: Once you know the value of "cut", say 1.5, it's easy to do it in Gnuplot (outside Matlab): gnuplot> cut=1.5; plot "prof300s.dat" u 1:3 w lines lw 2 , cut lw 3 e. Is this value of cut a good choice here? does it really represent half-maximum of the bump ? (note that the "base" value of B is 1, not zero). Figure out a better expression for setting "cut". f. Now (copy and) modify your FWHM.m code (from previous lab), insert it into "lab.m" as a function subprogram, Set "cut" according to e, and find the FWHM of the B array. Suppress output with ";". Insert appropriate comments. g. Your code should print out (nicely, with fprintf): "FWHM of bacteria at time 300 sec is" FWHM_value "microns, at height" cut_value

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

ISBN: 1583474013, 978-1583474013

More Books

Students also viewed these Databases questions

Question

=+What kinds of problems need to be overcome?

Answered: 1 week ago

Question

=+Describe an important trade-off you recently faced

Answered: 1 week ago