matlab-load


MATLAB - Load data file with a string file name


I am writing a Matlab program that loads a data file created in another C++ program.
planet = input('What is the name of your planet? ', 's')
data_file = strcat(planet, '.dat')
load(data_file);
data_file;
x = data_file(:,1);
y = data_file(:,2);
plot (x,y,'r*')
The program takes the name of the planet as the user input, then concatenates ".dat" to the end of the planet name. This gives, for example, "earth.dat," which is the name of the file created by the other C++ program.
I have made sure that the data file being loaded is in the correct folder; however, MATLAB still gives an error when I run the program.
What is the correct command for loading this file?
Thank you!
try using this instead:
planet = input('What is the name of your planet? ', 's')
filename=[num2str(planet) '.dat'];
data_file=load(filename);
x = data_file(:,1);
y = data_file(:,2);
plot (x,y,'r*')

Related Links

MATLAB - Load data file with a string file name
load() - ignoring a given string

Categories

HOME
xml
eclipse
assembly
design-patterns
sitecore
graphics
javacc
edge
static-site
aws-cli
visual-studio-emulator
python-multithreading
mvc5
accessibility
pattern-matching
enthought
pega
mod-security
filechannel
stellar.js
eip
dimensional-modeling
easyphp
git-extensions
simpleitk
ag
react-toolbox
exit
highstock
mount
game-theory
tiki-wiki
fable-f#
pylons
utorrent
weather
wacom
login-script
pdw-file-browser
filesystemwatcher
tasm
resolution
httr
servermanager
manova
corruption
qtranslate
yii2-user
libjpeg
java-websocket
d3-force-directed
cvxpy
gets
cubism.js
stax
hadoop-2.7.2
seek
dotnetnuke-7
mongodb-php
nikeplus-api
ng-grid
lua-telegram-bot
sklearn-pandas
html-to-pdf
grass
spring-retry
ember-cli-rails
rdflib
liquid-layout
mirror
keyup
ansi
canvg
snoop
teamcity-9.1
mdichild
winginx
cfcache
artemis
light
nevron
flex++
dolby-audio-api
font-awesome-4.0.0
alice
saleslogix
rmiregistry
cross-database
fsevents
android-holo-everywhere
automationelement
cgbitmapcontextcreate
strsep
w3c-geolocation
collectionviewsource
photolibrary
opml
sifr
wordprocessingml
google-wave
escrow
application-planning

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App