CFD Online Logo CFD Online URL
Home > Forums > CFX

Making a contour plot in MALAB

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

LinkBack Thread Tools Display Modes
Old   July 18, 2008, 15:53
Default Making a contour plot in MALAB
Posts: n/a
Sponsored Links
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]);

  Reply With Quote
Sponsored Links

Old   July 21, 2008, 14:06
Default Re: Making a contour plot in MALAB
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:

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

  Reply With Quote


Thread Tools
Display Modes

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
swak4foam building problem GGerber OpenFOAM Installation 54 April 24, 2015 16:02
Unable to view contour plot on a plane azurespirit ANSYS 0 May 23, 2011 08:35
contour plot help jesse@uconn FLUENT 0 February 15, 2010 20:05
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 20:08
DecomposePar links against liblamso0 with OpenMPI jens_klostermann OpenFOAM Bugs 11 June 28, 2007 17:51

Sponsored Links

All times are GMT -4. The time now is 12:30.