-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<Function code> - plotSectionDatas.m - sliceSectionData.m <Test code> - test.m <Test data> - test_raw_data.mat
- Loading branch information
Showing
4 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
function [] = plotSectionDatas(rawData, selAxis, axisParamMatrix, shapeOfLine) | ||
%% Figure | ||
figure('name', 'Plotting Sliceed Data'); | ||
|
||
%% Subplot setting | ||
% parameters | ||
[figureNum, ~] = size(axisParamMatrix); | ||
axisParamNum = zeros(1, figureNum); % parameters of each figure | ||
for fig_idx = 1:figureNum | ||
axisParamNum(fig_idx) = sum(~isnan(axisParamMatrix(fig_idx, :))); | ||
end | ||
% subplot size | ||
subFigNum_ROW = ceil(sqrt(figureNum)); | ||
subFigNum_COL = ceil(figureNum / ceil(sqrt(figureNum))); | ||
|
||
%% Plotting | ||
selAxis = lower(selAxis); | ||
for fig_idx = 1:figureNum | ||
if (axisParamNum(fig_idx) == 0) | ||
continue; | ||
end | ||
if (figureNum ~= 1) | ||
subplot(subFigNum_ROW, subFigNum_COL, fig_idx); % set subplot idx | ||
end | ||
|
||
legendString = string(1:axisParamNum(fig_idx)); % initialization | ||
for param_idx = 1:axisParamNum(fig_idx) | ||
hold on; | ||
plotData = sliceSectionData(rawData, selAxis, axisParamMatrix(fig_idx, param_idx)); % slicing 3-D plot | ||
plot(1:length(plotData), plotData, shapeOfLine); % plotting sliced data | ||
hold off; | ||
|
||
xlim([1, length(plotData)]); | ||
legendString(param_idx) = "" + string(selAxis) + " = " + string(axisParamMatrix(fig_idx, param_idx)); | ||
ylabel('z value'); | ||
if (selAxis == 'x') | ||
xlabel('y value'); | ||
elseif (selAxis == 'y') | ||
xlabel('x value'); | ||
end | ||
end | ||
legend(legendString); | ||
end | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
function selData = sliceSectionData(rawData, selAxis, axisParams) | ||
selAxis = lower(selAxis); | ||
if (selAxis == 'x') | ||
selData = rawData(axisParams, :); | ||
elseif (selAxis == 'y') | ||
selData = rawData(:, axisParams); | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
%% Lu175 | ||
clc; clear all; | ||
close all; | ||
format long; format compact; | ||
|
||
tic | ||
|
||
%% Process | ||
% Load data | ||
load('test_raw_data.mat'); | ||
|
||
% Raw data plot | ||
figure('name', '5 Transmitter'); | ||
mesh(FiveTransmitter); | ||
figure('name', '3 Transmitter'); | ||
mesh(ThreeTransmitter); | ||
|
||
% Delta plot | ||
figure('name', '5 Transmitter - 3 Transmitter'); | ||
mesh(FiveTransmitter - ThreeTransmitter); | ||
figure('name', '3 Transmitter - 5 Transmitter'); | ||
mesh(ThreeTransmitter - FiveTransmitter); | ||
|
||
%% | ||
% DEFINITION OF PLOTTING FUNCTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
% plotSectionDatas(rawData, selAxis, axisParamMatrix, shapeOfLine) | ||
% rawData : Raw data from excel files. | ||
% ex) FiveTransmitter | ||
% selAxis : Select one axis. (x or y) | ||
% ex) 'x' or 'X' / 'y' or 'Y' | ||
% axisParamMatrix : You can use 'subplot'(ROWs) & 'hold on'(COLs) finctions. | ||
% ex) See example under this help docs. | ||
% shapeOfLine : line property (color, shape) | ||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
|
||
% Select x values | ||
plotSectionDatas(FiveTransmitter, 'x', [1, 101, 151, 201, 301], '-'); | ||
|
||
% Select y values | ||
plotSectionDatas(FiveTransmitter, 'y', [1:40:301], '-'); | ||
|
||
% How to use axisParamMatrix parameter (nan -> for blank) | ||
params = [ | ||
11, 16, nan, nan; ... % Row NO.1 -> subplot NO.1 | ||
31, 36, 41, 46; ... % Row NO.2 -> subplot NO.2 | ||
51, 56, nan, nan; ... % Row NO.3 -> subplot NO.3 | ||
71, 76, 81, 86; ... % Row NO.4 -> subplot NO.4 | ||
91, 96, nan, nan; ... % Row NO.5 -> subplot NO.5 | ||
111, 116, 121, nan; ... % Row NO.6 -> subplot NO.6 | ||
131, 136, 141, nan; ... % Row NO.7 -> subplot NO.7 | ||
151, 156, 161, nan; ... % Row NO.8 -> subplot NO.8 | ||
]; | ||
plotSectionDatas(FiveTransmitter, 'x', params, '-'); | ||
|
||
% Also you can use ':' operator to choose slice parameter values | ||
params = [ | ||
71:10:101; ... % Row NO.1 -> subplot NO.1 | ||
111:10:141; ... % Row NO.2 -> subplot NO.2 | ||
151:10:181; ... % Row NO.3 -> subplot NO.3 | ||
191:10:221; ... % Row NO.4 -> subplot NO.4 | ||
]; | ||
plotSectionDatas(FiveTransmitter, 'y', params, '-'); | ||
|
||
|
||
%% | ||
toc |
Binary file not shown.