want ideas for contour, z is not a function for x,y
Show older comments
I'm begginer this.
I want draw a gragh using "contour".
I know the way of this is contour(x,y,Z) at help.
here, Z is function for x,y.
is it only this rule?
I want use this with Z is constant.
for example,
x y z
1 .2 10
2 .3 11
3 .4 12
4 .5 13
5 .6 14
as you can see, Z is not a function for x,y, constant.
Can I draw that using contour(or contourc, contourf... series of contour)?
How to ~ plz~
Answers (2)
Walter Roberson
on 7 Oct 2015
Z does not need to be related to x and y. For example,
x = sort(rand(1,10));
y = sort(rand(1,15));
z = rand(15,10);
contour(x, y, z);
1 Comment
Walter Roberson
on 7 Oct 2015
If the problem is that your Z is not a grid, then you need to use griddata() or scatteredinterpolant or triscatteredinterp
Yes. Just use
contour(X,Y,Z)
8 Comments
Byungsoo Yoo
on 7 Oct 2015
Thorsten
on 7 Oct 2015
Sorry, I do not get what you want. Please provide some more details.
Byungsoo Yoo
on 7 Oct 2015
Walter Roberson
on 7 Oct 2015
No, Z is a variable that has shape length(y) by length(x). Z is not a function! You can assign arbitrary values to Z, like in my example where I showed how you could use rand().
x = 1 : 5;
y = 0.1 : .1 : .5;
z = [1 2 3 1 3; 4 7 1 4 8; -3 -3 -3 11 2; 0 12 5 5 5; 9 8 7 3 3]; %SEE, a CONSTANT
contour(x, y, z)
There is no requirement that z be calculated at all.
Saif Aleslam Abh
on 12 Dec 2015
I was wondering if Z is Matrix 1*1. How can I draw it
Walter Roberson
on 12 Dec 2015
Saif, are your x and y something larger than 1 x 1? Is your Z intended to be the same for all of the locations? Or do you only have a single point? If you only have a single point then what do you expect the contour plot to look like?
Saurabh Das
on 2 Jul 2020
Walter, what if my X, Y and Z matrices are 1x900. Why can't I plot a contour for it?
Categories
Find more on Contour Plots 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!