Extracting numerical data from text file

#Terrain File

Terrain.mat#Start Point (xs,ys)
-4.8 4.0

From the code above I am trying to extract “-4.8” and save it as xs, and “4.0” saved as ys. I don’t know how to tell matlab to look for the “#” that will be at the beginning of every category.

this is the project text file code please convert to project.text file for solving.

#This is a project file for MAE8 Spring 2014

#Terrain File
Terrain.mat

#Start Point (xs,ys)
-4.8 4.0

#End Point (xe,ye)
4.8 -4.8
#Number of Way Points
2

#Way Points (xwp,ywp)
-0.5 4.8
4.7 0.8

NOTE:-

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help , Finance Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

If all you need is that start point coordinates, then about the simplest is just

>> [xs ys]=textread('project.txt','%f %f', 1, ...
'headerlines',4,'commentstyle','shell');
>> disp([xs ys])
-4.8000 4.0000

If, otoh, you need the other info as well, then it’s essentially the same presuming you’ll do a little post-processing —

>> [xs ys]=textread('project.txt','%f %f', ...
'headerlines',4,'commentstyle','shell');
>> disp([xs ys])
-4.8000 4.0000
4.8000 -4.8000
2.0000 0
-0.5000 4.8000
4.7000 0.8000
>>

The only difference in the textread is the removal of the count of 1 to limit the first past to the one record; it instead iterates over the entire file from the 7th line on.

Note the #waypoints record is returned as [2 0]; hence one can use

SEE COMPLETE ANSWER CLICK THE LINK

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store