10-17-2011, 09:59 PM | #1 |
smoke wheat hail satin
Join Date: Sep 2006
Location: LA baby
Age: 36
Posts: 5,704
|
MATLAB - The Language of Technical Computing
Love it or hate it, it's a high level computing language and an excellent analysis tool. I know we have some aspiring engineers in college who either are, or are soon to be immersed in this program and will be looking for help. The learning curve is extremely high, especially if you have no prior experience with programming. In this thread, you can post your code, ask for help from those of us who are more experienced, show people cool things they never knew about MATLAB, "code golf" or simply just show off.
If you want to display computer code properly, please use the code tags as shown below. If you are unaware of how to do that, simply quote this post and you will see the necessary BBCode. Code:
Place any code inside the code tags and it will be automatically formatted. This will make it easier for people to help you. Last edited by foilman8805; 10-17-2011 at 10:03 PM.. |
02-8-2012, 09:31 PM | #2 |
FFR Player
Join Date: May 2007
Posts: 1,134
|
Re: MATLAB - The Language of Technical Computing
Wow haven't posted in ages...
Does anyone know of a good site that gives tutorials on MATLAB? I'm struggling with it in my engineering class. |
02-8-2012, 09:34 PM | #3 |
.... :.. .:. ::
Join Date: Mar 2007
Posts: 1,031
|
Re: MATLAB - The Language of Technical Computing
what are you doing with it??
you can search for matlab exchange on google to get some programs similar to what you are doing. EDIT: http://www.mathworks.com/matlabcentral/fileexchange/ |
02-8-2012, 09:50 PM | #4 |
smoke wheat hail satin
Join Date: Sep 2006
Location: LA baby
Age: 36
Posts: 5,704
|
Re: MATLAB - The Language of Technical Computing
tango, what kind of help are you looking for?
|
02-8-2012, 09:50 PM | #5 |
FFR Player
Join Date: May 2007
Posts: 1,134
|
Re: MATLAB - The Language of Technical Computing
We learned for-loops, if-or statements, array manipulations and more. I mainly don't understand for-loops. For instance, I was given a 5D array with length of 10 10 20 10 10, and told to use nested for-loops to find the maximum number in the array.
Do you have any advice on how to learn programming more efficiently? This is my first programming class and I'm having a rough time haha. Example of a problem: Write a loop that finds the number under 1000 with the greatest number of unique prime factors. (Since many numbers under 1000 have the same `greatest' number of unique prime factors, find only the FIRST number that meets this criterion.) I had Code:
for vector = 1:10 factors(vector) = length(unique(factor(vector))); %Creates vector of the lengths of unique prime factors end Last edited by tangomango; 02-8-2012 at 09:56 PM.. |
02-8-2012, 09:55 PM | #6 |
smoke wheat hail satin
Join Date: Sep 2006
Location: LA baby
Age: 36
Posts: 5,704
|
Re: MATLAB - The Language of Technical Computing
The only advice is to program, program and program more. Occasionally seek help from people who know more than you. That's really it. You have to immerse yourself in order to get better. Practice makes perfect, etc.
And for a beginning programming class, I'm hoping what you really meant was you have a 1D array with 5 elements (length of 5). MATLAB doesn't handle 5D arrays lol. |
02-8-2012, 10:02 PM | #7 |
FFR Player
Join Date: May 2007
Posts: 1,134
|
Re: MATLAB - The Language of Technical Computing
To clarify the 5D problem, I was given temperature data from 5 variables (x,y,z,t,s). I'd like to clarify more but it was a quiz problem and I don't really remember the specifics.
|
02-8-2012, 10:05 PM | #8 | |
smoke wheat hail satin
Join Date: Sep 2006
Location: LA baby
Age: 36
Posts: 5,704
|
Re: MATLAB - The Language of Technical Computing
Quote:
max(factors) will return the maximum number in the array you named factors in your for loop. |
|
02-8-2012, 10:14 PM | #9 |
FFR Player
Join Date: May 2007
Posts: 1,134
|
Re: MATLAB - The Language of Technical Computing
The problem I'm having is that when I try to find the location of the maximum value from 'factors', it does not seem to work. Instead of a displaying '6' as I would like it to, it gives me 1.
Code:
for vector = 6:10 factors(vector) = length(unique(factor(vector))); %Creates vector of the lengths of unique prime factors a = find(max(factors)); end disp(a) Last edited by tangomango; 02-8-2012 at 10:16 PM.. |
02-8-2012, 10:16 PM | #10 |
smoke wheat hail satin
Join Date: Sep 2006
Location: LA baby
Age: 36
Posts: 5,704
|
Re: MATLAB - The Language of Technical Computing
If you want to find the location:
[a,b] = find(max(factors)); will return the index value of the largest number in the array by row and column, respectively. Then you'd want to do: disp(factors(a,b)) |
02-8-2012, 10:48 PM | #11 |
smoke wheat hail satin
Join Date: Sep 2006
Location: LA baby
Age: 36
Posts: 5,704
|
Re: MATLAB - The Language of Technical Computing
Write a loop that finds the number under 1000 with the greatest number of unique prime factors. (Since many numbers under 1000 have the same `greatest' number of unique prime factors, find only the FIRST number that meets this criterion.)
Code:
for i = 1:999 x(i) = length(unique(factor(i))); end y = ind2sub(size(x),find(x==max(x))); answer = min(y); disp('The answer is:') disp(answer) Last edited by foilman8805; 02-9-2012 at 08:27 PM.. |
02-12-2012, 10:45 PM | #12 |
FFR Player
Join Date: May 2007
Posts: 1,134
|
Re: MATLAB - The Language of Technical Computing
I'm a little confused at this part:
Code:
y = ind2sub(size(x),find(x==max(x))); answer = min(y); |
02-12-2012, 10:52 PM | #13 |
smoke wheat hail satin
Join Date: Sep 2006
Location: LA baby
Age: 36
Posts: 5,704
|
Re: MATLAB - The Language of Technical Computing
Dude, when you see something in MATLAB you don't immediately know and you want to know what it does you should consult the help files.
Type in the command window "help ind2sub". It'll provide a much better explanation than I can give. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|