To plot contour as per the value in array (square matrix)

4 views (last 30 days)
sanjeet
sanjeet on 1 Jul 2015
Commented: Mike Garrity on 1 Jul 2015
I wannt to plot contour plot for a array containing the values of number(no of droplet) as n_drop and mass array value. The x and y co-ordinate are in a different array- x1, y1 and z1 The difficulty is the contour not being clear and I tried scatter also. But the need is to present the data as visual format in color distinction or by contour. Please guide me if any idea regarding the contour or coloring scheme
subplot(2,2,1)
scatter(y1,z1,floor(radius1*10^7))
xlabel('x'); ylabel('z');hold on
grid on;
title(sprintf('2D plane z-y view for drop'));
% Part II ploting the values in required contour level
m2=max(n_drop);
m1=2 %mean(n_drop)*0.2;
subplot(2,2,2)
contourlevel = m1:((m2-m1)/10):m2; % Required contour for 10 scale to 100
Cont = contour(y1,z1,n_drop,contourlevel); %Array rotation to match needed display
% set(Cont,'LineStyle','none');
xlabel('x'); ylabel('z');
% clabel(Cont);
grid on;
title('Contour lines for number of drop');
subplot(2,2,3)
m2=max(mass);
m1=mean(diag(mass))*0.2;
contourlevel2 = m1:((m2-m1)/10):m2; % Required contour for 10 scale to 100
contour(y1,z1,mass,contourlevel2); %Array rotation to match needed display
xlabel('x'); ylabel('z');
% clabel(Cont);
grid on;
title(sprintf('Stream lines for mass in spray area'));
subplot(2,2,4)
% smoothening by convolutiuon
F = [.05 .1 .05; .1 .4 .1; .05 .1 .05];
n_drop = conv2(n_drop,F,'same');
title(sprintf('Stream lines for no of drop -smooth in spray area'));
Cont = contour(y1,z1,n_drop,contourlevel); %Array rotation to match needed display
title(sprintf('Stream lines for number of droplet in spray area'));
<<
>>
  2 Comments
Mike Garrity
Mike Garrity on 1 Jul 2015
What's the shape of y1, z1, and n_drop here?
size(y1)
size(z1)
size(n_drop)
It's very unusual to be able to pass the same data into scatter & contour (as you're doing here) and get something meaningful.
My guess is that the contour isn't really doing what you think it's doing. A good way to see what contour is doing is to pass the same data into surf. If you get a reasonably smooth looking surface, then the output of contour is probably trustworthy, but if your surface is a scrambled mess I wouldn't use contour.
Contour is expecting gridded data. It supports some odd shaped inputs so that it can handle curvilinear, but I don't think that's what you're trying to do. I expect that you're missing a gridding step before handing your data to contour.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!