How to convert trajectory of the current vector to grayscale.
37 views (last 30 days)
Show older comments
Dear sir,
Could you make help for coding. I attached the data.mat
First, I read the three phase current. After I use clarke transform and I get current vector (Is).
1. I established a 60×60 2D matrix to depict the trajectory, with (30,30) as the origin and 1 step size.
2. I calculate the trajectory of the current vector on the α-β plane. But it is not like the below picture.

why is it that picture?

3. The probability that each point in the current vector trajectory falls into a certain grid is calculated as the grayscale of the point.
4. I want use mean value filtering algorithm to filter out the points with low probability,
5. I want normalize the value of each pixel in the 2D matrix according to the min-max normalization.
But ı get very bad result like that. The circle should be large.

The circle should be large, like below picture

load("data.mat")
Ia = data(:,1);
Ib = data(:,2);
Ic = data(:,3);
%% Clarke (3 phase → αβ)
I_alpha = Ia;
I_beta = (1/sqrt(3))*(Ia + 2*Ib); % Clarke formülü
% Current vector
Is = I_alpha + 1j*I_beta;
plot(Is)
%% 1⃣ 60×60 2D matrix
grid_size = 60; % 60x60 matrix
origin = [30, 30]; % (30,30) origin
step = 1; % 1
traj_matrix = zeros(grid_size, grid_size);
%% 2⃣ Place the current vector on 2D matrix
for i = 1:length(Is)
Ia_val = real(Is(i));
Ib_val = imag(Is(i));
xi = round(Ia_val/step + origin(1));
yi = round(Ib_val/step + origin(2));
if xi >= 1 && xi <= grid_size && yi >= 1 && yi <= grid_size
traj_matrix(yi, xi) = traj_matrix(yi, xi) + 1;
end
end
plot(traj_matrix)
%%3⃣ Probability matrix (grayscale intensity)
traj_prob = traj_matrix / sum(traj_matrix(:));
%%4⃣ Mean Value filtering (noise reduction)
kernel = fspecial('average', [3 3]); % 3x3 mean filter
traj_filtered = imfilter(traj_prob, kernel, 'replicate');
%%5⃣ Min–max normalization
min_val = min(traj_filtered(:));
max_val = max(traj_filtered(:));
traj_norm = (traj_filtered - min_val) / (max_val - min_val);
%%6⃣ visualization
figure;
imshow(traj_norm, []);
title('Normalized 2D Current Vector Trajectory (αβ plane)');
xlabel('\alpha axis');
ylabel('\beta axis');
colormap('gray');
colorbar;
0 Comments
Accepted Answer
Matt J
on 9 Oct 2025 at 3:16
Edited: Matt J
on 9 Oct 2025 at 3:45
Maybe this is what you wanted?
load("data.mat")
Ia = data(:,1);
Ib = data(:,2);
Ic = data(:,3);
%% Clarke (3 phase → αβ)
I_alpha = Ia;
I_beta = (1/sqrt(3))*(Ia + 2*Ib); % Clarke formülü
plot(I_alpha, I_beta,'.'); axis equal
%% 1⃣ 60×60 2D matrix
grid_size = 60; % 60x60 matrix3
traj_prob = histcounts2(I_alpha,I_beta, grid_size, Norm="prob");
%%4⃣ Mean Value filtering (noise reduction)
kernel = fspecial('average', [3 3]); % 3x3 mean filter
traj_norm = rescale( imfilter(traj_prob, kernel, 'rep') );
%%6⃣ visualization
figure;
imagesc(traj_norm)
title('Normalized 2D Current Vector Trajectory (αβ plane)');
xlabel('\alpha axis');
ylabel('\beta axis');
colormap gray; colorbar;
2 Comments
Matt J
on 13 Oct 2025 at 14:42
Edited: Matt J
on 13 Oct 2025 at 15:03
(1) You can use padarray and imresize to adjust the proportions of the circle, relative to the surrounding grid area.
(2) The spatial distribution of (I_alpha, I_beta) is not uniform around the circumference of the circle. Therefore, the image values will not be either.
(4) If the graph is showing a perfect circle, then your data is a perfect circle.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!






