imagesc graph axis setting probelm in Matlab Appdesigner

2 visualizzazioni (ultimi 30 giorni)
...
%% 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 Commenti
준홍
준홍 il 22 Mag 2024
The caution message said that this kind of variables can't use dot indexing.
VBBV
VBBV il 23 Mag 2024
Modificato: VBBV il 23 Mag 2024

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

Accedi per commentare.

Risposte (1)

VBBV
VBBV il 23 Mag 2024
Modificato: VBBV il 24 Mag 2024
@준홍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

Prodotti


Release

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by