From: Steven Lord on

"Philip " <philipbrudnicki(a)jhu.edu> wrote in message
news:hpcp5p$f88$1(a)fred.mathworks.com...
> "Steven Lord" <slord(a)mathworks.com> wrote in message
> <hpcoij$667$1(a)fred.mathworks.com>...
>>
>> "Philip " <philipbrudnicki(a)jhu.edu> wrote in message
>> news:hpbrh0$2tr$1(a)fred.mathworks.com...
>> > Thanks for the response. I was a little afraid I wasn't too clear.
>> >
>> > I was actually able to make it through that part but now I am having
>> > some trouble with plotting.
>> > so I am trying to do pcolor of a nxn matrix. for some reason, however,
>> > I get this error:
>> >
>> > ??? Error using ==> surface
>> > Value must be numeric
>> >
>> > Error in ==> pcolor at 71
>> > hh = surface(zeros(size(x)),x,'parent',cax);
>> >
>> >
>> >
>> >
>> > in that instance, I ran pcolor(x) where x was a 10x10 matrix of 1 and
>> > 0.
>>
>> From your description, I suspect that x is a logical array -- you can
>> confirm this by looking at WHOS, using CLASS on x, or using ISLOGICAL on
>> x. If so, the error message is correct -- the value must be numeric, and
>> the following returns false:
>>
>> isnumeric(logical([0 1]))
>>
>> Convert your logical array into a double array using DOUBLE and pass the
>> double version into PCOLOR.
>>
>> --
>> Steve Lord
>> slord(a)mathworks.com
>> comp.soft-sys.matlab (CSSM) FAQ:
>> http://matlabwiki.mathworks.com/MATLAB_FAQ
>
> Thanks Steve. The problem is, that that error for x is in the matlabs
> native pcolor mfile that is run when I excecute pfile. My input into
> pcolor is a 1,0 array however.

Yes -- it is your input to PCOLOR that's the logical array that's causing
the error. Try:

pcolor(double(x))

and I think the problem will be resolved.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


From: ImageAnalyst on
Alternatively you might want to use
imshow(x, []);
Note the use of [] to scale the intensity for proper display (i.e. so
you can see it).
imshow() can take logical, integer, and floating point images directly
without casting to another data type.
I've never liked pcolor anyway.
From: Philip on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <6d5a75af-7f92-4a4f-8159-5fdf0797948c(a)r1g2000yqj.googlegroups.com>...
> Alternatively you might want to use
> imshow(x, []);
> Note the use of [] to scale the intensity for proper display (i.e. so
> you can see it).
> imshow() can take logical, integer, and floating point images directly
> without casting to another data type.
> I've never liked pcolor anyway

thanks, I am going to stick with pcolor and circshift since those are what the prof recommended. Right now, though, I am having trouble updating my chart.

So I have a master function that for 1:X steps, runs a function that opens matrix of 1 and 0 of the same size, but different arrangment. Now, this master function is supposed to send that data for each output to my plot function, which is:

function plotgrid(grid)
pcolor(double(grid));
caxis ([0 1]);
shading flat

drawnow
end

now since I am such a novice in this, i sometimes forget the simple steps. When I run my master function, I get one stationary figure that doesnt change. I want the figure, however, to be updating which each step so i can see the flowing change of 1 and 0s.

Thanks guys.
From: Philip on
"Philip " <philipbrudnicki(a)jhu.edu> wrote in message <hpdj16$99b$1(a)fred.mathworks.com>...
> ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <6d5a75af-7f92-4a4f-8159-5fdf0797948c(a)r1g2000yqj.googlegroups.com>...
> > Alternatively you might want to use
> > imshow(x, []);
> > Note the use of [] to scale the intensity for proper display (i.e. so
> > you can see it).
> > imshow() can take logical, integer, and floating point images directly
> > without casting to another data type.
> > I've never liked pcolor anyway
>
> thanks, I am going to stick with pcolor and circshift since those are what the prof recommended. Right now, though, I am having trouble updating my chart.
>
> So I have a master function that for 1:X steps, runs a function that opens matrix of 1 and 0 of the same size, but different arrangment. Now, this master function is supposed to send that data for each output to my plot function, which is:
>
> function plotgrid(grid)
> pcolor(double(grid));
> caxis ([0 1]);
> shading flat
>
> drawnow
> end
>
> now since I am such a novice in this, i sometimes forget the simple steps. When I run my master function, I get one stationary figure that doesnt change. I want the figure, however, to be updating which each step so i can see the flowing change of 1 and 0s.
>
> Thanks guys.

So I have made it just about to the end. I am trying to finish up by having my output plot be red and blue, not black and white.

here is the code:

grid=smooth3(grid);
patch(isosurface(double(grid))); caxis([0 1])
view(3);
camlight
lighting flat
drawnow

I would have thought setting the caxis would have done it, since grid is all 1 and 0, but it still remains black and white.

Thanks,
Phil