How to convert trajectory of the current vector to grayscale.
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;
Accepted Answer
More Answers (0)
Categories
Find more on Measurements and Spatial Audio 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!






