SV650.org - SV650 & Gladius 650 Forum



Idle Banter For non SV and non bike related chat (and the odd bit of humour - but if any post isn't suitable it'll get deleted real quick).
There's also a "U" rating so please respect this. Newbies can also say "hello" here too.

Reply
 
Thread Tools
Old 20-08-09, 10:09 PM   #1
yorkie_chris
Noisy Git
Mega Poster
 
yorkie_chris's Avatar
 
Join Date: Apr 2007
Location: Halifax/Leeds
Posts: 26,645
Default Oi geeks. Anyone know MATLAB?

Quote:
Originally Posted by matlab

clear
%clear the history
gridsize = menu ('what size matrix would you like?','10 by 10','40 by 40','80 by 80','custom size');
%ask user what size grid
if gridsize == 1
x=10;
y=10;
elseif gridsize == 2
x=40;
y=40;
elseif gridsize == 3
x=80;
y=80;
elseif gridsize == 4
%ask for custom size game
prompt={'Enter in the x dimension','Enter in the y dimension'};
%name of the query
name='Custom game size';
%lines
numlines=1;
%the default setting
defaultanswer={'20','20'};
%creates the box. input stored to matrix X
X=inputdlg(prompt,name,numlines,defaultanswer);
%split matrix X into seperate variables x and y to create grid with
end
x =X(1,1)
y =X(2,1)

select = menu ('Random starting condition or input .lif file?','Randomise','Load file');
if select == 1
A= randint(x,y);
elseif select == 2
[filename, pathname] = uigetfile('*.*', 'Pick any file')

end

Trying to form random binary matrix A.

Brings up the menus and stuff fine, works fine with the preset sizes 10x10 40x40 etc. BUT if you select a custom matrix size it throws up

Quote:
??? Error using ==> randint at 60
Only numeric arguments are accepted.

Error in ==> GOL at 64
A= randint(X);
And it's starting to annoy. It will do this even if you set the custom size to the same as a preset one.
Checking on the main command menu shows that x and y are set to integers from the X matrix as they're supposed to be. What the b*ll*cky-f*** is wrong with it?

Gah!
__________________
Currently Ex Biker
Now rebuilding a 63' fishing trawler as a dive boat
yorkie_chris is offline   Reply With Quote
Old 21-08-09, 08:13 AM   #2
flymo
Member
Mega Poster
 
flymo's Avatar
 
Join Date: Jan 2008
Location: North West
Posts: 3,124
Default Re: Oi geeks. Anyone know MATLAB?

Chris, not familiar with this particular product but...

The section of code you have that does
x =X(1,1)
y =X(2,1)

is setting the x and y variables to non-integer values just before the section that uses the radint function. What does this function do?
flymo is offline   Reply With Quote
Old 21-08-09, 09:10 AM   #3
Baph
Guest
 
Posts: n/a
Default Re: Oi geeks. Anyone know MATLAB?

inputdlg() reads strings, not numbers...

Use str2num().
  Reply With Quote
Old 21-08-09, 09:29 AM   #4
yorkie_chris
Noisy Git
Mega Poster
 
yorkie_chris's Avatar
 
Join Date: Apr 2007
Location: Halifax/Leeds
Posts: 26,645
Default Re: Oi geeks. Anyone know MATLAB?

Don't have the program here, so apologies if this is painfully obvious. (and generic apologies for the n00b questions!)

So I would swap the inputdlg for str2num? Or use str2num to extract the numbers from the inputdlg results?

Also I don't understand why if you check back on the main screen, it has set x and y to integers. Or so it appears. But I will have a look when I get home.

Quote:
Originally Posted by flymo View Post
Chris, not familiar with this particular product but...

The section of code you have that does
x =X(1,1)
y =X(2,1)

is setting the x and y variables to non-integer values just before the section that uses the radint function. What does this function do?
set x to row 1 column 1 of matrix X
set y to row 2 column 1 of matrix X
__________________
Currently Ex Biker
Now rebuilding a 63' fishing trawler as a dive boat
yorkie_chris is offline   Reply With Quote
Old 21-08-09, 09:38 AM   #5
Baph
Guest
 
Posts: n/a
Default Re: Oi geeks. Anyone know MATLAB?

Quote:
Originally Posted by yorkie_chris View Post
So I would swap the inputdlg for str2num? Or use str2num to extract the numbers from the inputdlg results?

Also I don't understand why if you check back on the main screen, it has set x and y to integers. Or so it appears. But I will have a look when I get home.
MATLAB is a funny old language.

use inputdlg() to read keyboard input, then pass that through str2num() before using in the matrix (or in the x=X(1,1) statement... eg, x=str2num(X(1,1)).) ... Probably neater doing it seperately though.

And the main screen shows what it does because it's frankly, pretty random, and attempts class cast conversions where it sees fit.

Always did hate MATLAB... But if you're seriously stuck, I know a few folks studying engineering & the likes that use it regular. In fact, one of the lads sat next to me right now does...
  Reply With Quote
Old 21-08-09, 09:40 AM   #6
yorkie_chris
Noisy Git
Mega Poster
 
yorkie_chris's Avatar
 
Join Date: Apr 2007
Location: Halifax/Leeds
Posts: 26,645
Default Re: Oi geeks. Anyone know MATLAB?

Right what's his phone number and how many gallons of ale is it going to cost me

Bit of background, it's coursework for my engineering course, needing to do conways game of life program with some GUI stuff.
__________________
Currently Ex Biker
Now rebuilding a 63' fishing trawler as a dive boat
yorkie_chris is offline   Reply With Quote
Old 21-08-09, 09:54 AM   #7
flymo
Member
Mega Poster
 
flymo's Avatar
 
Join Date: Jan 2008
Location: North West
Posts: 3,124
Default Re: Oi geeks. Anyone know MATLAB?

very similar to vbscript this, most of the time it guesses data type correctly but occasionally gets its knickers in a twist.
flymo is offline   Reply With Quote
Old 21-08-09, 11:23 AM   #8
Baph
Guest
 
Posts: n/a
Default Re: Oi geeks. Anyone know MATLAB?

Quote:
Originally Posted by yorkie_chris View Post
Right what's his phone number and how many gallons of ale is it going to cost me
The lad working today knows more MATLAB than I do, but he's still not fantastic TBH.

Another one of the lads will be in work in a couple of hours. He's done more MATLAB than the other guy, and if he's up to some beer money (won't be much) I'll drop you a PM with his contact details.

  Reply With Quote
Old 21-08-09, 01:02 PM   #9
yorkie_chris
Noisy Git
Mega Poster
 
yorkie_chris's Avatar
 
Join Date: Apr 2007
Location: Halifax/Leeds
Posts: 26,645
Default Re: Oi geeks. Anyone know MATLAB?

That bit now works. Cheers Baph.

Next bit now. Woop.
__________________
Currently Ex Biker
Now rebuilding a 63' fishing trawler as a dive boat
yorkie_chris is offline   Reply With Quote
Reply


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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
For PBX Geeks TSM Idle Banter 5 08-08-09 03:34 PM
geeks- help me Quiff Wichard Idle Banter 24 30-01-09 11:27 AM
Oi geeks. yorkie_chris Idle Banter 64 23-11-08 10:06 PM
So then Geeks Viney Idle Banter 4 06-08-07 11:21 AM
Only for the geeks falc Idle Banter 13 08-02-07 06:21 AM


All times are GMT. The time now is 10:46 AM.


Powered by vBulletin® - Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.