# Making a contour plot in MALAB

 Register Blogs Members List Search Today's Posts Mark Forums Read

 July 18, 2008, 15:53 Making a contour plot in MALAB #1 Mick Guest   Posts: n/a I need help with matlab. This is my error ??? Attempted to access Z(0,0); index must be a positive integer or logical. My data is 3 columns separated by a tab space. The first column is the x , the second column is the y, and the third is the z. There is 3240 numbers in each column (36 * 95) I don't think that the z is the only error and i know that MATLAB begins from 1 not zero. My data looks like this: 0 1 3 0 2 8 ... ... ... 35 94 4 % Open file, fid keeps track of it. fid = fopen('contourplot'); % Scan all rows and interpret as three integers separated by space C = textscan(fid, '%d %d %d', 'CollectOutput', 0); % Done with file, close it fclose(fid); % Assign the data to vectors for easier access x = C{1}; y = C{2}; z = C{3}; % Get data to determin how big matrix to zero maxx = max(x); maxy = max(y); samples = length(z); % zero it Z = zeros(maxx, maxy); % assign the right values from z to the right % coordinates in the matrix for i = 1:samples Z(x(i), y(i)) = z(i); end % Settings for the gradient lowest = 0; highest= 2; levels = 20; % Get uniform distribution of levels between highest and lowest v = lowest : (highest - lowest) / levels : highest; % Draw the contour contour(Z, v); % Set the axis [xMin xMax yMin yMax] axis([0 35 0 94]);

 July 21, 2008, 14:06 Re: Making a contour plot in MALAB #2 UnderwaterAlex Guest   Posts: n/a This is a CFX forum, not matlab. Maybe someone can help you here, but I bet you'd have better luck here: http://www.mathworks.com/matlabcentral/newsreader/ I don't particularly understand what you are asking, but the problem is that somewhere a function is trying to access Z(0,0) and my guess is that it is in the drawing of the contour. From my limited experience to create a contour plot successfully in Matlab, the easiest was is to use meshgrid to create the location variables. Probably the first part of my response (posting to a matlab forum) is much more helpful than the second part. Best of luck -Alex

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post GGerber OpenFOAM Installation 54 April 24, 2015 16:02 azurespirit ANSYS 0 May 23, 2011 08:35 jesse@uconn FLUENT 0 February 15, 2010 20:05 allenzhao OpenFOAM Installation 127 January 30, 2009 20:08 jens_klostermann OpenFOAM Bugs 11 June 28, 2007 17:51

All times are GMT -4. The time now is 19:10.