(HELP)Who knows anything about MATLAB? - LS1TECH

Go Back   LS1TECH > LS1-LS2-LS3-LS6-LS7 PERFORMANCE > Advanced Engineering Tech
Log In 
Search


Advanced Engineering Tech
For the more hardcore LS1TECH residents
Sponsored by
Whipple Super Chargers


(HELP)Who knows anything about MATLAB?

Reply
 
Thread Tools Search this Thread
Old 02-13-2010, 04:55 PM   #1
TECH Regular
 
Sammyboy's Avatar
 
Trader Rating: 9
Join Date: Jul 2008
Location: Honolulu, HI
Posts: 426
Default (HELP)Who knows anything about MATLAB?

Question: Write a function named mymax that takes as input a list of numbers and returns the maximum value in the list and its location (index). You may NOT use Matlab's max command. Your function should show an error message and return 0 and 0 if it is called with the wrong number of inputs or if the input isn't a one row matrix.

What I have so far:

function Q1=mymax[list]
%input a list of values
%output-maximum value
%output-value position
x_max=list(1)
% sets the initial value of the list to the maximum value
for ii = 1:length(list)
% runs the if statement below for the entire list of numbers
if x_max < x(ii)
% if statement which checks whether the current value is higher than the next value
x_max = x(ii)
% if x(3) is higher than x(1), and so on, then x_max will become the third value.
end
for list(1)< list(i)
x_max=list(i)
if list(x)
error('wrong number of inputs')
i=0;
return;
end
if
error('the input isnt a one row matrix')
i=0;
return;
end
__________________
Quote:
Originally Posted by PewterY2KZ28 View Post
Talk about a resurection....!! Nice job buddy.. Car looks great!
Sammyboy is offline   Reply With Quote
Old 02-16-2010, 10:46 AM   #2
On The Tree
 
Trader Rating: 0
Join Date: Jul 2007
Location: Kansas City, Kansas
Posts: 101
Default

This sounds like a HW assignment. Why else would you not be aloud to use the max command.

Quote:

function Q1 = mymax[list]

%output-maximum value
%output-value position


x_max=list(1)

% sets the initial value of the list to the maximum value

for ii = 1:length(list)

% runs the if statement below for the entire list of numbers

if x_max < x(ii), % I think you want list(ii) not x(ii), bc you do not have a variable x.

% if statement which checks whether the current value is higher than the next value

x_max = x(ii)

% if x(3) is higher than x(1), and so on, then x_max will become the third value.

end % This just ends the if statement.

for list(1) < list(i) % were you wanting a nested for for loop? What is i?

x_max = list(i)

if list(x) % You havent declared a variable x.
error('wrong number of inputs')
i=0;
return;
end
if % No parameters for the if statement
error('the input isnt a one row matrix')
i=0;
return;
end
Your errors could be because Im not sure if the varibles are passing outside of the of the for loops. I havent taken a MATLAB class since last spring so I dont remember. The variables might need to be declared as global.

Sorry if nothing I added helped. I am by no means a MATLAB expert.

Is there any more info about the problem?

Could you post your mymax function? Edit: this is the mymax function.

Use the MATLAB help.
__________________
2001 A4 Camaro B4C, SLP Lid, UMI Subframe Connectors, UMI LCA's, UMI LCA Relocation Brackets, Transgo HD2, 243 Ls2 Heads, Comp Cams High Tech Pushrods, LT Headers, Wait4Me Performance Tune, Cutout, Powerbond UD Puley, RedStar Performance Torque Converter, 1.94 60ft - 8.48 1/8@84.13 - 13.17@104.29
http://img135.imageshack.us/img135/4...500x100mj0.jpg

Last edited by MikeMoss; 02-16-2010 at 11:57 AM.
MikeMoss is offline   Reply With Quote
Old 02-18-2010, 03:11 AM   #3
OWN3D BY MY PROF!
 
Beaflag VonRathburg's Avatar
 
Trader Rating: 176
Join Date: Feb 2006
Location: Jax Beach, Florida
Posts: 9,155
Default

Don't get caught by your teacher. That's all I have to say on the subject. You may end up with a fancy new user title.
Beaflag VonRathburg is offline   Reply With Quote
Old 02-21-2010, 04:38 PM   #4
TECH Fanatic
 
Ryans99ls1's Avatar
 
Trader Rating: 16
Join Date: Dec 2007
Location: OH & MI
Posts: 1,376
Default

Quote:
Originally Posted by MikeMoss View Post
This sounds like a HW assignment. Why else would you not be aloud to use the max command.



Your errors could be because Im not sure if the varibles are passing outside of the of the for loops. I havent taken a MATLAB class since last spring so I dont remember. The variables might need to be declared as global.

Sorry if nothing I added helped. I am by no means a MATLAB expert.

Is there any more info about the problem?

Could you post your mymax function? Edit: this is the mymax function.

Use the MATLAB help.
It sounds like you are referring more to a C++ type program.. but idk im VERY new to C++ and more in depth programming. i didnt really read into OP's program much though because i recently just stopped using MATLAB and switched to C++(which im not a fan of) so my MATLAB skills are fading. ill have to think about this one and get back to you(the OP)
__________________
99 TA-Precision 76mm GTS-H, Baker Engineering Built Iron LS1, T56 Magnum, 9in, E85
My Build -http://ls1tech.com/forums/forced-ind...-page-3-a.html
01 Hardtop Formula Firehawk-Lid, Ported TB, LT's, Ypipe, Factory SLP dual-dual, 6 speed, Garage queen
Ryans99ls1 is offline   Reply With Quote
Reply


Tags
matlab, matrix, max, mymax, position, subframe


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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


 

All times are GMT -5. The time now is 10:37 PM.


Powered by vBulletin® Version 3.8.7 AC2
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.
Advertising - Terms of Service - Privacy Statement - Terms of Service - JOBS
Emails & Contact Details