MacInsiders Logo

Similar Threads
Thread Thread Starter Forum Replies Last Post
Math 2Z03 MATLAB nerdlife Academics 21 10-13-2010 12:34 AM

MATLAB help?

 
Old 02-07-2011 at 07:51 PM   #1
ishk33
Senior Member
Join Date: Jul 2008
Posts: 215

Thanked: 4 Times
Liked: 12 Times




MATLAB help?
Hi,

I needed some help with matlab. How do i upload the data from a file to matlab? What commands are used?

I'd appreciate your help!
Old 02-07-2011 at 07:53 PM   #2
jajas
Account Disabled by User
Join Date: Jun 2010
Posts: 254

Thanked: 15 Times
Liked: 49 Times




I usually find it easier to input the data into an excel spreadsheet and use the command xlsread

This link will give you a better idea of how to use the command : http://www.mathworks.com/help/techdoc/ref/xlsread.html
Old 02-07-2011 at 07:57 PM   #3
ishk33
Senior Member
Join Date: Jul 2008
Posts: 215

Thanked: 4 Times
Liked: 12 Times




Oh okay!
But the professor wanted us to make a file: abc.txt
and then upload the data. It's one of the requirements. :(
Old 02-07-2011 at 08:00 PM   #4
jajas
Account Disabled by User
Join Date: Jun 2010
Posts: 254

Thanked: 15 Times
Liked: 49 Times




Than I think you should be looking into this command. It works basically the same way. http://www.mathworks.com/help/techdoc/ref/textread.html
Old 02-07-2011 at 08:03 PM   #5
ishk33
Senior Member
Join Date: Jul 2008
Posts: 215

Thanked: 4 Times
Liked: 12 Times




Okayy I'll try it out. Thanks

The prof asked us to start the assignment with C:\ and then get to the file somehow? This isn't really working for me.

Am I doing anything wrong?
Old 02-07-2011 at 08:09 PM   #6
jajas
Account Disabled by User
Join Date: Jun 2010
Posts: 254

Thanked: 15 Times
Liked: 49 Times




Can you clarify what you mean by starting the assignment with C:\ ?

But all that means is you are defining a path (link) inside your hard drive to where the file you are going to be using is located.

If you paste the code and a sample of the text file you have so far in this thread I could try debugging it.
Old 02-07-2011 at 08:14 PM   #7
ishk33
Senior Member
Join Date: Jul 2008
Posts: 215

Thanked: 4 Times
Liked: 12 Times




For example: My text file is called abc.txt

So I was asked to start it this way:

C:/
dir
cd temp
dir
load abc.txt
Old 02-07-2011 at 08:32 PM   #8
jajas
Account Disabled by User
Join Date: Jun 2010
Posts: 254

Thanked: 15 Times
Liked: 49 Times




Sorry, I am not familiar with this method. Try following the steps on the second link I sent you. It should guide you through it. I was never constrained to using just text files so I am only accustomed to spreadsheets.
Old 02-07-2011 at 08:44 PM   #9
AnguishedEnd
Elite Member
Join Date: Aug 2008
Posts: 781

Thanked: 89 Times
Liked: 103 Times




Quote:
Originally Posted by ishk33 View Post
For example: My text file is called abc.txt

So I was asked to start it this way:

C:/
dir
cd temp
dir
load abc.txt
Code:
userpath('C:/<file directory here>') dir fid = fopen('<filename>.txt'); F = fread(fid, '*char')' fclose(fid);
Hope that was helpful.

If your unfamiliar with command line then check out this http://ss64.com/nt/
Also for textfiles: http://www.mathworks.com/help/techdoc/ref/f16-5702.html#f16-14491
__________________
In Mechatronics? Visit mms.mcmaster.ca for program & event info!

Last edited by AnguishedEnd : 02-07-2011 at 08:55 PM.
Old 02-07-2011 at 08:57 PM   #10
ishk33
Senior Member
Join Date: Jul 2008
Posts: 215

Thanked: 4 Times
Liked: 12 Times




>> userpath('C:\<user>')
??? Error using ==> userpath
Too many input arguments.

>> userpath('user')
??? Error using ==> userpath
Too many input arguments.

>> userpath('C:\user')
??? Error using ==> userpath
Too many input arguments.




dunno where I'm going wrong :(

I'm sorry if I made a mistake somewhere, I'm just really new to this! :(
Old 02-07-2011 at 09:07 PM   #11
AnguishedEnd
Elite Member
Join Date: Aug 2008
Posts: 781

Thanked: 89 Times
Liked: 103 Times




Quote:
Originally Posted by ishk33 View Post
>> userpath('C:\<user>')
??? Error using ==> userpath
Too many input arguments.

>> userpath('user')
??? Error using ==> userpath
Too many input arguments.

>> userpath('C:\user')
??? Error using ==> userpath
Too many input arguments.




dunno where I'm going wrong :(

I'm sorry if I made a mistake somewhere, I'm just really new to this! :(
I'm not to sure about that sorry. Found this though something about starting matlab from a shortcut causing problems.

EDIT: You last one should have worked "userpath('C:\user')" . That is if you do have a user folder on your C drive...
__________________
In Mechatronics? Visit mms.mcmaster.ca for program & event info!

Last edited by AnguishedEnd : 02-07-2011 at 09:22 PM.
Old 02-07-2011 at 09:28 PM   #12
Bhaltair
Elite Member
Join Date: Aug 2009
Posts: 405

Thanked: 36 Times
Liked: 158 Times




Please, do not speak of MATLAB. It brings nightmare to the people in Math 2ZZ3.

http://www.math.mcmaster.ca/gabardo/M2ZZ3.html

Check HW1 & HW2

Anyways, will this help?

http://web.cecs.pdx.edu/~gerry/MATLAB/plotting/loadingPlotData.html

xxsumz says thanks to Bhaltair for this post.
Old 02-07-2011 at 09:41 PM   #13
ishk33
Senior Member
Join Date: Jul 2008
Posts: 215

Thanked: 4 Times
Liked: 12 Times




Wow, looking at that assignment just made my situation 100 times worse -_-

I dont think thats much of a help, cuz he wants us to write specific commands that just don't seem to work for me

>.<

I just wanna upload a goddamn file :(
Old 02-07-2011 at 09:59 PM   #14
AnguishedEnd
Elite Member
Join Date: Aug 2008
Posts: 781

Thanked: 89 Times
Liked: 103 Times




Just out of curiosity what version of MATLAB are you running?

If you have a really old version running on your home computer you can SSH and use the one on the mac servers. I think its R2010a? Just a suggestion.
__________________
In Mechatronics? Visit mms.mcmaster.ca for program & event info!
Old 02-07-2011 at 10:14 PM   #15
ishk33
Senior Member
Join Date: Jul 2008
Posts: 215

Thanked: 4 Times
Liked: 12 Times




It's MATLAB 7.1



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



McMaster University News and Information, Student-run Community, with topics ranging from Student Life, Advice, News, Events, and General Help.
Notice: The views and opinions expressed in this page are strictly those of the student(s) who authored the content. The contents of this page have not been reviewed or approved by McMaster University or the MSU (McMaster Students Union). Being a student-run community, all articles and discussion posts on MacInsiders are unofficial and it is therefore always recommended that you visit the official McMaster website for the most accurate up-to-date information.

Copyright © MacInsiders.com All Rights Reserved. No content can be re-used or re-published without permission. MacInsiders is a service of Fullerton Media Inc. | Created by Chad
Originally Powered by vBulletin®, Copyright © 2019 MH Sub I, LLC dba vBulletin. All rights reserved. | Privacy | Terms