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
assembly
adal
angular-formly
hessian
spring-data-redis
pclxl
rendering
alsa
nested-if
jax-ws
banner
flume
syntaxnet
java.util.logging
cmdb
automatic-ref-counting
selenium-ide
qsqlquery
mongodb-csharp
mathprog
dimensional-modeling
asp.net-mvc-viewmodel
user-experience
kendo-mobile
articulate-storyline
angular-routing
imageresizer
pylons
appirater
fragment-backstack
has-and-belongs-to-many
ms-access-2003
sinch
uitapgesturerecognizer
alm
send
angularjs-material
hibernate-validator
clickjacking
hreflang
roblox
lint
sql-server-ce
demo
mongoose-schema
apache-stanbol
subclipse
oim
pom.xml
fwrite
nanoc
libgphoto2
spring-integration-sftp
tinymce-3
activeperl
static-cast
subnet
cpu-cache
py2neo
objectscript
filenet
reachability
simplepie
builtins
ziparchive
windows-azure-queues
ng-grid
installshield-2010
delta
android-dateutils
eigenvector
tracker-enabled-dbcontext
data-protection
gcloud-ruby
kiosk
libav
beanstalk
halcon
design-principles
libvlc
directdraw
sapscript
viola-jones
typemock
amiga
sha512
liquid-layout
cwrsync
shopizer
crowd
big-ip
punycode
trdion2011
functional-java
renderer
xmltodict
isqlquery
ice-cube
unit-of-work
beaker-testing
facebook-timeline
asplinkbutton
panda3d
onmousemove
cakephp-1.2
rmiregistry
infobright
agility.js
user-tracking
promotion-code
filemerge
lr
multiplatform
strsep
appledoc
jqueryform
zend-rest
tabpanel
sifr
burndowncharts
interop-domino
windows-identity

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