Clear Filters
Clear Filters

read data to plot

2 views (last 30 days)
Cesar Cardenas
Cesar Cardenas on 30 Apr 2023
Answered: Debraj Maji on 14 Nov 2023
Hello, I'm trying to read the data in the zip file attached with this code but I'm getting errors, not sure how I could plot the data contained in this file? any help will be greatly appreciated. Thanks
%centroids (improve this by averaging the 4 corners)
xc=x(1:end-1,1:end-1)+diff(x(:,1:end-1))/2 +diff(x(1:end-1,:),[],2)/2;
yc=y(1:end-1,1:end-1)+diff(y(:,1:end-1))/2 +diff(y(1:end-1,:),[],2)/2;
b=reshape(a(nx*ny*2+1:end),[nx-1,ny-1,nfields]);%nine dependent variables
%plot pressure
view(2);shading flat;axis image;axis([-1,1,-1,1])
Cesar Cardenas
Cesar Cardenas on 3 May 2023
Thanks, I've been trying that, but I have not been able to figure it out. can you give me a bit more detail? Thanks
Cris LaPierre
Cris LaPierre on 4 May 2023
Sure. Can you provide the values of nx, ny, and nfields at this point in your code?

Sign in to comment.

Answers (1)

Debraj Maji
Debraj Maji on 14 Nov 2023
I see that you are trying to read data form a file with a .DAT extension. I have downloaded the zip file shared and upon inspection have found that there is a mismatch in the file name used for reading the file. You can find the required correction below:
The corresponding figure obtained using the shared data is attached below:
Make sure to add the path for the data file is added before the script is run.
I hope this helps!


Find more on Visual Exploration in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!