I am getting Error using pcolor? What could be the issue

17 views (last 30 days)
This is the code
clear
close all
load('Data.mat');
ts=MOM_SPC.ts;
Az=MOM_SPC.header.az;
range=MOM_SPC.header.ngs;
Va=MOM_SPC.header.va;
deltaR=MOM_SPC.header.dR;
Range=(1:range).*deltaR/1000;
M=MOM_SPC.header.nfft;
m=1:M;
az=1:Az;
c=3*10^8;
f=3*10^9;
lambda=c/f;
Ts=(2*Va)/lambda;
Pt=(Ts/M).*(sum(abs(ts(m)).^2));
Zt=10*log10(Pt) + 20.*log10(Range(az));
Rt=(1/(M-1).*(sum((conj(ts(1:M-1)).*(ts(2:M))))));
Vrt=-(lambda/(4*pi*Ts)).*(angle(Rt));
Sf=(abs(fliplr(fftshift(fft(ts(m)))))).^2*(Ts/M);
Pf=1/M.*sum(Sf);
Zf=10*log10(Pf) + 20.*log10(Range(az));
Sn=Sf/(sum(Sf));
[peak,km]=max(Sn); A=0;
for k= (km-(M/2)):(km+(M/2)-1)
mod_index=mod(k,M);
if mod_index==0
mod_index=M;
end
A= A+ k*Sn(mod_index);
end
Vrf=(A-(M/2))*(lambda/(2*M*Ts));
x =(sin(az.*pi/180))'.*Range;
y =(cos(az.*pi/180))'.*Range;
figure; pcolor(x,y,Zt); shading flat; title('Radar Reflectivity,Z (dB) in Time Domain');
figure; pcolor(x,y,Vrt); shading flat; title('Radial Velocity Vr (m/s) in Time Domain');
figure; pcolor(x,y,Zf); shading flat; title('Radar Reflectivity,Z (dB) in frequency Domain');
figure; pcolor(x,y,Vrf); shading flat; title('Radial Velocity Vr (m/s) in frequency Domain');
  2 Comments
Geoff Hayes
Geoff Hayes on 22 Apr 2021
Oluwafunmilayo - what is the error message? Please copy and paste the full error message to this question.
Oluwafunmilayo Williams
Oluwafunmilayo Williams on 22 Apr 2021
Error using pcolor (line 58) Color data input must be a matrix.
Error in project (line 49) Pcolor (x,y,Zt);

Sign in to comment.

Answers (1)

Prasanna
Prasanna on 24 Apr 2024
Hi,
The error you're encountering, "Color data input must be a matrix," indicates that the dimensions of x, y, and the data you're trying to plot (Zt, Vrt, Zf, Vrf) do not align in a way that allows pcolor to interpret them as a grid of color values.
For pcolor to work, x, y, and the data matrix must all be of the same size, forming a complete grid. To fix the same, you can ensure ‘Range’,az’ and the dimensions of plotting variables (Zt, Vrt, Zf, Vrf)’ are correct. pcolor” cannot be made from scattered points, it essentially takes a matrix as input.
For more information on pseudocolor plots, refer the following documentation: https://www.mathworks.com/help/matlab/ref/pcolor.html
Hope this helps.

Categories

Find more on Polar 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!