Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: writing user specified files

Subject: writing user specified files

From: Ender

Date: 16 Jul, 2008 17:03:29

Message: 1 of 15

I want MATLAB to upload a specific file based on user
commands. The first part of my code asked what file would
you like to upload. I have previous experience using
the "strcmpi" command to ask for data from the user. The
last time I used the command I asked for specific input
then I compared the string of what the user chose. If the
input matched the string, MATLAB would do a certain
command.

This time I want MATLAB to write the string that the user
specifies into a dlmread command.

Example:

user types: myfun.txt

MATLAB will then input myfun.txt into dlmread(myfun.txt)

How do I do this

--Ender--

Subject: Re: writing user specified files

From: Peter Boettcher

Date: 16 Jul, 2008 17:23:47

Message: 2 of 15

"Ender " <jr147@msstate.edu> writes:

> I want MATLAB to upload a specific file based on user
> commands. The first part of my code asked what file would
> you like to upload. I have previous experience using
> the "strcmpi" command to ask for data from the user. The
> last time I used the command I asked for specific input
> then I compared the string of what the user chose. If the
> input matched the string, MATLAB would do a certain
> command.
>
> This time I want MATLAB to write the string that the user
> specifies into a dlmread command.
>
> Example:
>
> user types: myfun.txt
>
> MATLAB will then input myfun.txt into dlmread(myfun.txt)
>
> How do I do this

Ender, you've been hanging out around this group for a while time now,
and I think you already have the experience to know what a string
variable is.

What datatype does dlmread take? What datatype does your user input
function return? Can you display the results of that input?

How do you call dlmread now? If it's a literal string, how would put
that into a variable and call it from there?

How do think you would call dlmread with your user input?


-Peter

Subject: Re: writing user specified files

From: Ender

Date: 18 Jul, 2008 20:53:02

Message: 3 of 15

Peter Boettcher <boettcher@ll.mit.edu> wrote in message
<muysku9bv4s.fsf@G99-Boettcher.llan.ll.mit.edu>...
> "Ender " <jr147@msstate.edu> writes:
>
> > I want MATLAB to upload a specific file based on user
> > commands. The first part of my code asked what file
would
> > you like to upload. I have previous experience using
> > the "strcmpi" command to ask for data from the user.
The
> > last time I used the command I asked for specific
input
> > then I compared the string of what the user chose. If
the
> > input matched the string, MATLAB would do a certain
> > command.
> >
> > This time I want MATLAB to write the string that the
user
> > specifies into a dlmread command.
> >
> > Example:
> >
> > user types: myfun.txt
> >
> > MATLAB will then input myfun.txt into dlmread
(myfun.txt)
> >
> > How do I do this
>
> Ender, you've been hanging out around this group for a
while time now,
> and I think you already have the experience to know what
a string
> variable is.
>
> What datatype does dlmread take? What datatype does
your user input
> function return? Can you display the results of that
input?
>
> How do you call dlmread now? If it's a literal string,
how would put
> that into a variable and call it from there?
>
> How do think you would call dlmread with your user input?
>
>
> -Peter


I don't understand what is wrong with this code. I think
that MATLAB is not passing the string to user entry or the
import file is not recognizing the variable that is
attached to user_entry. Here is an example of my code:


disp('What is the name of the file.extension')
disp('that you want to upload?')
user_entry = input(' ','s');

% Import the file
PIT_MKV_2 = importdata('user_entry');

I am using the MATLAB created function to read both the
text and the numbers in the file that is being uploaded.

This is the error that I am getting:

??? Error using ==> importdata at 114
Unable to open file.

Error in ==> Practice_user_input at 15
PIT_MKV_2 = importdata('user_entry');



Subject: Re: writing user specified files

From: Steven Lord

Date: 18 Jul, 2008 21:00:47

Message: 4 of 15


"Ender " <jr147@msstate.edu> wrote in message
news:g5qvre$l6f$1@fred.mathworks.com...
> Peter Boettcher <boettcher@ll.mit.edu> wrote in message
> <muysku9bv4s.fsf@G99-Boettcher.llan.ll.mit.edu>...
>> "Ender " <jr147@msstate.edu> writes:

*snip example*

> I don't understand what is wrong with this code. I think
> that MATLAB is not passing the string to user entry or the
> import file is not recognizing the variable that is
> attached to user_entry. Here is an example of my code:
>
>
> disp('What is the name of the file.extension')
> disp('that you want to upload?')
> user_entry = input(' ','s');
>
> % Import the file
> PIT_MKV_2 = importdata('user_entry');
>
> I am using the MATLAB created function to read both the
> text and the numbers in the file that is being uploaded.
>
> This is the error that I am getting:
>
> ??? Error using ==> importdata at 114
> Unable to open file.
>
> Error in ==> Practice_user_input at 15
> PIT_MKV_2 = importdata('user_entry');

Hint: these two statements are very different.

PIT_MKV_2 = importdata('user_entry');
PIT_MKV_2 = importdata(user_entry);

just like these two DISP statements are different:

x = 1;
disp('x')
disp(x)

--
Steve Lord
slord@mathworks.com


Subject: Re: writing user specified files

From: Peter Boettcher

Date: 18 Jul, 2008 21:04:00

Message: 5 of 15

"Ender " <jr147@msstate.edu> writes:

> Peter Boettcher <boettcher@ll.mit.edu> wrote in message
> <muysku9bv4s.fsf@G99-Boettcher.llan.ll.mit.edu>...

>> Ender, you've been hanging out around this group for a while time
>> now, and I think you already have the experience to know what a
>> string variable is.
>>
>> What datatype does dlmread take? What datatype does your user input
>> function return? Can you display the results of that input?
>>
>> How do you call dlmread now? If it's a literal string, how would put
>> that into a variable and call it from there?
>>
>> How do think you would call dlmread with your user input?
>
> I don't understand what is wrong with this code. I think
> that MATLAB is not passing the string to user entry or the
> import file is not recognizing the variable that is
> attached to user_entry. Here is an example of my code:
>
>
> disp('What is the name of the file.extension')
> disp('that you want to upload?')
> user_entry = input(' ','s');
>
> % Import the file
> PIT_MKV_2 = importdata('user_entry');
>
> I am using the MATLAB created function to read both the
> text and the numbers in the file that is being uploaded.

You are ignoring my questions. They are designed to help you figure
this out on your own, which you are fully capable of.

You are confusing literal strings and variables. One of them is
surrounding by quotes. The other is not.

Stop after you finish user_entry. Can you display the results of the
input call (hint: disp)? How? What does the function call look like?

In other words, play around in the workspace if you can't get something
to work.

-Peter

Subject: Re: writing user specified files

From: Ender

Date: 28 Jul, 2008 16:09:02

Message: 6 of 15

Peter Boettcher <boettcher@ll.mit.edu> wrote in message
<muywsji9a67.fsf@G99-Boettcher.llan.ll.mit.edu>...
> "Ender " <jr147@msstate.edu> writes:
>
> > Peter Boettcher <boettcher@ll.mit.edu> wrote in
message
> > <muysku9bv4s.fsf@G99-Boettcher.llan.ll.mit.edu>...
>
> >> Ender, you've been hanging out around this group for
a while time
> >> now, and I think you already have the experience to
know what a
> >> string variable is.
> >>
> >> What datatype does dlmread take? What datatype does
your user input
> >> function return? Can you display the results of that
input?
> >>
> >> How do you call dlmread now? If it's a literal
string, how would put
> >> that into a variable and call it from there?
> >>
> >> How do think you would call dlmread with your user
input?
> >
> > I don't understand what is wrong with this code. I
think
> > that MATLAB is not passing the string to user entry or
the
> > import file is not recognizing the variable that is
> > attached to user_entry. Here is an example of my code:
> >
> >
> > disp('What is the name of the file.extension')
> > disp('that you want to upload?')
> > user_entry = input(' ','s');
> >
> > % Import the file
> > PIT_MKV_2 = importdata('user_entry');
> >
> > I am using the MATLAB created function to read both
the
> > text and the numbers in the file that is being
uploaded.
>
> You are ignoring my questions. They are designed to
help you figure
> this out on your own, which you are fully capable of.
>
> You are confusing literal strings and variables. One of
them is
> surrounding by quotes. The other is not.
>
> Stop after you finish user_entry. Can you display the
results of the
> input call (hint: disp)? How? What does the function
call look like?
>
> In other words, play around in the workspace if you
can't get something
> to work.
>
> -Peter


Yes, I was ignoring your response. I am coming here for
help not to be lectured on my proficiency in MATLAB. If I
knew how to write the script correctly I would not be
asking questions in the forum I would be working for
MATLAB. Steven Lord was helpful. Instead of lecturing me
about my skills in MATLAB he was actually willing to point
me in the write direction so that I could solve my own
problem. That is why I ignored you.

I am going to try the suggestion that Steven made and
maybe it will solve the problem. I didn't realize at the
time that there was a difference in using x='user_entry'
as compared to x=user_entry.

--Ender--

Subject: Re: writing user specified files

From: Peter Boettcher

Date: 28 Jul, 2008 16:42:37

Message: 7 of 15


"Ender " <jr147@msstate.edu> writes:

> Yes, I was ignoring your response. I am coming here for
> help not to be lectured on my proficiency in MATLAB. If I
> knew how to write the script correctly I would not be
> asking questions in the forum I would be working for
> MATLAB. Steven Lord was helpful. Instead of lecturing me
> about my skills in MATLAB he was actually willing to point
> me in the write direction so that I could solve my own
> problem. That is why I ignored you.
>
> I am going to try the suggestion that Steven made and
> maybe it will solve the problem. I didn't realize at the
> time that there was a difference in using x='user_entry'
> as compared to x=user_entry.

*plonk*

Subject: Re: writing user specified files

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 28 Jul, 2008 16:46:05

Message: 8 of 15

In article <g6kquu$4ng$1@fred.mathworks.com>, Ender <jr147@msstate.edu> wrote:

>Yes, I was ignoring your response. I am coming here for
>help not to be lectured on my proficiency in MATLAB. If I
>knew how to write the script correctly I would not be
>asking questions in the forum

I re-read the exchange, and I could not see anywhere in which
Peter "lectured" you on anything. What I did see was Peter
contributing time to guide you through the steps you need in
order to be able to answer these kinds of questions yourself,
so that next time you would not need to rely on the newsgroup
for these kinds of issues.

>Steven Lord was helpful. Instead of lecturing me
>about my skills in MATLAB he was actually willing to point
>me in the write direction so that I could solve my own
>problem.

Peter pointed you in the right direction so you could solve
your own problem.

Steven Lord's style is generally as a direct basic problem solver,
pointing out direct answers from the documentation or the bug list.
Peter's style, and (more so) my style, and (even more so) John D'Errico's
style, is a role as a teacher, prefering to answer in ways that get
the person thinking more precisely and clearly about what has to be
done, and we tend to concentrate more on the problem domains
(what is to be accomplished) rather than on the mechanics of doing it
(though we answer a lot of those questions too, when the -what- is
clear.) You might get a more direct answer to your immediate question
from Steven Lord, but in the long run, you'll probably learn more
from Peter or John or I (or from Roger Stafford, if you happen to be
working in a problem area that strikes his interest; there's a lot
to be learned from Roger!)
--
  "Eightly percent of the people in the world are fools and the
  rest of us are in danger of contamination." -- Walter Matthau

Subject: Re: writing user specified files

From: Peter Boettcher

Date: 16 Jul, 2008 17:23:47

Message: 9 of 15

"Ender " <jr147@msstate.edu> writes:

> I want MATLAB to upload a specific file based on user
> commands. The first part of my code asked what file would
> you like to upload. I have previous experience using
> the "strcmpi" command to ask for data from the user. The
> last time I used the command I asked for specific input
> then I compared the string of what the user chose. If the
> input matched the string, MATLAB would do a certain
> command.
>
> This time I want MATLAB to write the string that the user
> specifies into a dlmread command.
>
> Example:
>
> user types: myfun.txt
>
> MATLAB will then input myfun.txt into dlmread(myfun.txt)
>
> How do I do this

Ender, you've been hanging out around this group for a while time now,
and I think you already have the experience to know what a string
variable is.

What datatype does dlmread take? What datatype does your user input
function return? Can you display the results of that input?

How do you call dlmread now? If it's a literal string, how would put
that into a variable and call it from there?

How do think you would call dlmread with your user input?


-Peter

Subject: Re: writing user specified files

From: Ender

Date: 18 Jul, 2008 20:53:02

Message: 10 of 15

Peter Boettcher <boettcher@ll.mit.edu> wrote in message
<muysku9bv4s.fsf@G99-Boettcher.llan.ll.mit.edu>...
> "Ender " <jr147@msstate.edu> writes:
>
> > I want MATLAB to upload a specific file based on user
> > commands. The first part of my code asked what file
would
> > you like to upload. I have previous experience using
> > the "strcmpi" command to ask for data from the user.
The
> > last time I used the command I asked for specific
input
> > then I compared the string of what the user chose. If
the
> > input matched the string, MATLAB would do a certain
> > command.
> >
> > This time I want MATLAB to write the string that the
user
> > specifies into a dlmread command.
> >
> > Example:
> >
> > user types: myfun.txt
> >
> > MATLAB will then input myfun.txt into dlmread
(myfun.txt)
> >
> > How do I do this
>
> Ender, you've been hanging out around this group for a
while time now,
> and I think you already have the experience to know what
a string
> variable is.
>
> What datatype does dlmread take? What datatype does
your user input
> function return? Can you display the results of that
input?
>
> How do you call dlmread now? If it's a literal string,
how would put
> that into a variable and call it from there?
>
> How do think you would call dlmread with your user input?
>
>
> -Peter


I don't understand what is wrong with this code. I think
that MATLAB is not passing the string to user entry or the
import file is not recognizing the variable that is
attached to user_entry. Here is an example of my code:


disp('What is the name of the file.extension')
disp('that you want to upload?')
user_entry = input(' ','s');

% Import the file
PIT_MKV_2 = importdata('user_entry');

I am using the MATLAB created function to read both the
text and the numbers in the file that is being uploaded.

This is the error that I am getting:

??? Error using ==> importdata at 114
Unable to open file.

Error in ==> Practice_user_input at 15
PIT_MKV_2 = importdata('user_entry');



Subject: Re: writing user specified files

From: Steven Lord

Date: 18 Jul, 2008 21:00:47

Message: 11 of 15


"Ender " <jr147@msstate.edu> wrote in message
news:g5qvre$l6f$1@fred.mathworks.com...
> Peter Boettcher <boettcher@ll.mit.edu> wrote in message
> <muysku9bv4s.fsf@G99-Boettcher.llan.ll.mit.edu>...
>> "Ender " <jr147@msstate.edu> writes:

*snip example*

> I don't understand what is wrong with this code. I think
> that MATLAB is not passing the string to user entry or the
> import file is not recognizing the variable that is
> attached to user_entry. Here is an example of my code:
>
>
> disp('What is the name of the file.extension')
> disp('that you want to upload?')
> user_entry = input(' ','s');
>
> % Import the file
> PIT_MKV_2 = importdata('user_entry');
>
> I am using the MATLAB created function to read both the
> text and the numbers in the file that is being uploaded.
>
> This is the error that I am getting:
>
> ??? Error using ==> importdata at 114
> Unable to open file.
>
> Error in ==> Practice_user_input at 15
> PIT_MKV_2 = importdata('user_entry');

Hint: these two statements are very different.

PIT_MKV_2 = importdata('user_entry');
PIT_MKV_2 = importdata(user_entry);

just like these two DISP statements are different:

x = 1;
disp('x')
disp(x)

--
Steve Lord
slord@mathworks.com


Subject: Re: writing user specified files

From: Peter Boettcher

Date: 18 Jul, 2008 21:04:00

Message: 12 of 15

"Ender " <jr147@msstate.edu> writes:

> Peter Boettcher <boettcher@ll.mit.edu> wrote in message
> <muysku9bv4s.fsf@G99-Boettcher.llan.ll.mit.edu>...

>> Ender, you've been hanging out around this group for a while time
>> now, and I think you already have the experience to know what a
>> string variable is.
>>
>> What datatype does dlmread take? What datatype does your user input
>> function return? Can you display the results of that input?
>>
>> How do you call dlmread now? If it's a literal string, how would put
>> that into a variable and call it from there?
>>
>> How do think you would call dlmread with your user input?
>
> I don't understand what is wrong with this code. I think
> that MATLAB is not passing the string to user entry or the
> import file is not recognizing the variable that is
> attached to user_entry. Here is an example of my code:
>
>
> disp('What is the name of the file.extension')
> disp('that you want to upload?')
> user_entry = input(' ','s');
>
> % Import the file
> PIT_MKV_2 = importdata('user_entry');
>
> I am using the MATLAB created function to read both the
> text and the numbers in the file that is being uploaded.

You are ignoring my questions. They are designed to help you figure
this out on your own, which you are fully capable of.

You are confusing literal strings and variables. One of them is
surrounding by quotes. The other is not.

Stop after you finish user_entry. Can you display the results of the
input call (hint: disp)? How? What does the function call look like?

In other words, play around in the workspace if you can't get something
to work.

-Peter

Subject: Re: writing user specified files

From: Ender

Date: 28 Jul, 2008 16:09:02

Message: 13 of 15

Peter Boettcher <boettcher@ll.mit.edu> wrote in message
<muywsji9a67.fsf@G99-Boettcher.llan.ll.mit.edu>...
> "Ender " <jr147@msstate.edu> writes:
>
> > Peter Boettcher <boettcher@ll.mit.edu> wrote in
message
> > <muysku9bv4s.fsf@G99-Boettcher.llan.ll.mit.edu>...
>
> >> Ender, you've been hanging out around this group for
a while time
> >> now, and I think you already have the experience to
know what a
> >> string variable is.
> >>
> >> What datatype does dlmread take? What datatype does
your user input
> >> function return? Can you display the results of that
input?
> >>
> >> How do you call dlmread now? If it's a literal
string, how would put
> >> that into a variable and call it from there?
> >>
> >> How do think you would call dlmread with your user
input?
> >
> > I don't understand what is wrong with this code. I
think
> > that MATLAB is not passing the string to user entry or
the
> > import file is not recognizing the variable that is
> > attached to user_entry. Here is an example of my code:
> >
> >
> > disp('What is the name of the file.extension')
> > disp('that you want to upload?')
> > user_entry = input(' ','s');
> >
> > % Import the file
> > PIT_MKV_2 = importdata('user_entry');
> >
> > I am using the MATLAB created function to read both
the
> > text and the numbers in the file that is being
uploaded.
>
> You are ignoring my questions. They are designed to
help you figure
> this out on your own, which you are fully capable of.
>
> You are confusing literal strings and variables. One of
them is
> surrounding by quotes. The other is not.
>
> Stop after you finish user_entry. Can you display the
results of the
> input call (hint: disp)? How? What does the function
call look like?
>
> In other words, play around in the workspace if you
can't get something
> to work.
>
> -Peter


Yes, I was ignoring your response. I am coming here for
help not to be lectured on my proficiency in MATLAB. If I
knew how to write the script correctly I would not be
asking questions in the forum I would be working for
MATLAB. Steven Lord was helpful. Instead of lecturing me
about my skills in MATLAB he was actually willing to point
me in the write direction so that I could solve my own
problem. That is why I ignored you.

I am going to try the suggestion that Steven made and
maybe it will solve the problem. I didn't realize at the
time that there was a difference in using x='user_entry'
as compared to x=user_entry.

--Ender--

Subject: Re: writing user specified files

From: Peter Boettcher

Date: 28 Jul, 2008 16:42:37

Message: 14 of 15


"Ender " <jr147@msstate.edu> writes:

> Yes, I was ignoring your response. I am coming here for
> help not to be lectured on my proficiency in MATLAB. If I
> knew how to write the script correctly I would not be
> asking questions in the forum I would be working for
> MATLAB. Steven Lord was helpful. Instead of lecturing me
> about my skills in MATLAB he was actually willing to point
> me in the write direction so that I could solve my own
> problem. That is why I ignored you.
>
> I am going to try the suggestion that Steven made and
> maybe it will solve the problem. I didn't realize at the
> time that there was a difference in using x='user_entry'
> as compared to x=user_entry.

*plonk*

Subject: Re: writing user specified files

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 28 Jul, 2008 16:46:05

Message: 15 of 15

In article <g6kquu$4ng$1@fred.mathworks.com>, Ender <jr147@msstate.edu> wrote:

>Yes, I was ignoring your response. I am coming here for
>help not to be lectured on my proficiency in MATLAB. If I
>knew how to write the script correctly I would not be
>asking questions in the forum

I re-read the exchange, and I could not see anywhere in which
Peter "lectured" you on anything. What I did see was Peter
contributing time to guide you through the steps you need in
order to be able to answer these kinds of questions yourself,
so that next time you would not need to rely on the newsgroup
for these kinds of issues.

>Steven Lord was helpful. Instead of lecturing me
>about my skills in MATLAB he was actually willing to point
>me in the write direction so that I could solve my own
>problem.

Peter pointed you in the right direction so you could solve
your own problem.

Steven Lord's style is generally as a direct basic problem solver,
pointing out direct answers from the documentation or the bug list.
Peter's style, and (more so) my style, and (even more so) John D'Errico's
style, is a role as a teacher, prefering to answer in ways that get
the person thinking more precisely and clearly about what has to be
done, and we tend to concentrate more on the problem domains
(what is to be accomplished) rather than on the mechanics of doing it
(though we answer a lot of those questions too, when the -what- is
clear.) You might get a more direct answer to your immediate question
from Steven Lord, but in the long run, you'll probably learn more
from Peter or John or I (or from Roger Stafford, if you happen to be
working in a problem area that strikes his interest; there's a lot
to be learned from Roger!)
--
  "Eightly percent of the people in the world are fools and the
  rest of us are in danger of contamination." -- Walter Matthau

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics