contour plot getting error
2 次查看(过去 30 天)
显示 更早的评论
Hello,
I am trying to get two contour plots with my date below, and I'm getting error for the second one, I really appreciate your help to guide me,
clear all
close all
clc
[m,a]=meshgrid(0:1/11:1,0:5000:50000)
v=m.*a
[C,h]=contour(m,a,v);
set(h,'ShowText','on','TextStep',get(h,'LevelStep')*2);
colormap cool
%U=q/M^2
U=[1481.354 1232.613 1018.924 836.3533 681.2936 550.4372 440.7684 349.5441 275.1887 216.6139 170.5264]
KIAS=661*((U)*m.^2/1481).^(1/2)
figure
[A,B]=contour(m,a,KIAS);
set(B,'ShowText','on','TextStep',get(B,'LevelStep')*2);
colormap cool
采纳的回答
Walter Roberson
2013-9-3
Your KIAS comes out as 1 x 12. When you have a vector as the third argument of contour() then the vector is treated as the list of contour levels, not as Z.
After that, the contour() error checking gets confused about what exactly is wrong: the real problem it should be diagnosing at that point is that you would have provided only two coordinate matrices (X, Y) instead of one (Z) or three (X, Y, Z).
Remember, U is a row vector, so it is 1 x something, and when you do an algebraic matrix multiplication (1 x something) x matrix, then the result is going to be 1 x some dimension, rather than a rectangle.
You might perhaps be wanting to do some repmat() somewhere along the line. And maybe a transpose or three. I can't tell.
6 个评论
Walter Roberson
2013-9-4
As I wrote above,
The result would be the same as if you had repmat(KIAS,11,1) with your current KIAS definition -- which clearly would not give you nice contours.
Which is also why I wrote,
This is why we need to know mathematically what you expect for each KIAS entry.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Contour Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!