Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Help with a matrix with words
Replies: 1   Last Post: May 18, 2013 5:07 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
ferne17

Posts: 1
Registered: 5/18/13
Help with a matrix with words
Posted: May 18, 2013 2:52 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hello, I need help with my code because I'm trying to do a Island to work with cellular automaton and in the middle of the Island I need numbers, but I want that the Island have a Sea so in the edge I need the letter "M"! to identificate the Sea. Here is my code but Matlab send me an error, I hope someone can help me:
clc;
clear;
len=7;
GRID=zeros(len+2,len+2); %Matriz inicial de len+2 x len+2
for i=3:len
for j=3:len
GRID(i,j)=floor(3.99*rand); %matriz se rellena desde la (3,3) hasta (len,len)
end %
end %
for j=2:2:len+1 % el for es con len+1 y no len+2, porque sino
GRID(2,j)=1; % me rellenarĂ¡ la ultima columna qe es mar
end % y parte desde la segunda columna x el mar
for i=2:2:len+1
GRID(i,2)=1;
end
for j=2:2:len+1 % el for es con len+1 y no len+2, porque sino
GRID(len+1,j)=1; % me rellenarĂ¡ la ultima columna qe es mar
end
for i=2:2:len+1
GRID(i,len+1)=1;
end
%AHORA EL MAR
for j=1:len+2
GRID(1,j)={'M'};
end
for i=1:len+2
GRID(i,1)='M';
end
for j=1:len+2
GRID(len+2,j)='M';
end
for i=1:len+2
GRID(i,len+2)='M';
end
GRID

The following error occurred converting from cell to double:
Error using double
Conversion to double from cell is not possible.

Error in Prueba2 (line 24)
GRID(1,j)={'M'};

Greetings



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.