imagesc graph axis setting probelm in Matlab Appdesigner

2 次查看(过去 30 天)
...
%% Loop start
numRows = length(shiftedDistance);
numCols = app.MaxMeasCountEditField.Value;
if isempty(app.dataMatrix)
app.dataMatrix = nan(numRows, numCols);
end
app.stop_loop = false;
if isempty(app.Ascan_cnt)
app.Ascan_cnt = 0;
end
while app.Ascan_cnt <= app.MaxMeasCountEditField.Value && app.stop_loop == false
% Add new data on the dataMatrix
if app.Ascan_cnt > numCols
% If I need to add cols
app.dataMatrix = [app.dataMatrix, nan(numRows, 1)];
numCols = numCols + 1;
end
app.dataMatrix(:, app.Ascan_cnt + 1) = newData;
% NaN to Zero
app.dataMatrix(isnan(app.dataMatrix)) = 0;
% image update
imagesc(app.UIAxes3_1, [1 app.Ascan_cnt], [min(shiftedDistance) max(shiftedDistance)], app.dataMatrix);
% xlim set
if app.Ascan_cnt > 50
xlim(app.UIAxes3_1, [app.Ascan_cnt - 49 app.Ascan_cnt]);
else
xlim(app.UIAxes3_1, [1 50]);
end
% ylim set
ylim(app.UIAxes3_1, [min(shiftedDistance) max(shiftedDistance)]);
colormap(app.UIAxes3_1, 'gray');
axis(app.UIAxes3_1, 'tight');
set(app.UIAxes3_1, 'YDir', 'reverse');
clim(app.UIAxes3_1, [0, app.ImageScalingEditField.Value]);
...
My code is like those.
I have a problem on setting the X axis in the Matlab appdesigner imagesc.
I want to add measured datas one by one on the defined Matrix.
And, I want the initial X axis with 50 components, and moving through when components are over 50s.
But, the datas add along arbitrary value even not integer.
what is my problem?
  11 个评论
준홍
준홍 2024-5-22
The caution message said that this kind of variables can't use dot indexing.
VBBV
VBBV 2024-5-23
编辑:VBBV 2024-5-23

Ok. It may be for this reason, using sprintf function when you print to status text area value. This function prints output values in text or as character instead of numeric (double) values. Use without sprintf function as shown below

app.StatusTextArea.Value = app.Ascan_cnt

请先登录,再进行评论。

回答(1 个)

VBBV
VBBV 2024-5-23
编辑:VBBV 2024-5-24
@준홍Ok. It may be for this reason, using *sprintf* function when you print to status text area value. This function prints output values in text or as character instead of numeric (double) values. Use without |sprintf| function as shown below
app.StatusTextArea.Value = app.Ascan_cnt

类别

Help CenterFile Exchange 中查找有关 Installation and Operational Settings 的更多信息

产品


版本

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by