I have 11 binary datasets and I would like to generate a graph with the trace of the corresponding figures of the data-sets (all 297x258) with the y-axis and x-axis multiplied with a scale of (1.3*10^(-6)) and labelled 'Y-axis(μm)' and 'X-axis (μm)' respectively. The 11 datasets are stored in a cell (i.e. data1{1}
,...data1{11}
). Also if the plot can also label each trace with the name of the corresponding dataset it will be appreciated (i.e. data1{1},...
).
To plot this I start with finding the first non zero element in each column for all datasets, and then sum them up to plot the lines on top of each other.
Finally, I multiply the axis by the conversion constant you gave (raitio
below) and change the format to meet your requested style:
data = reshape(cell2mat(data1),297,258,[]);
S = size(data);
fnzc = zeros(S([1 3])); % first non zero in column
for k = 1:S(3)
csc = cumsum(data(:,:,k)>0,2); % on columns
fnzc(:,k) = csc(:,end);
end
ratio = 1.3*(10^(-6));
ax = axes;
plot(ax,(S(1):-1:1)*ratio,cumsum(fnzc,2)*ratio)
ax.XAxis.TickLabelFormat = '%2d';
ax.XAxis.Exponent = -6;
ax.YAxis.TickLabelFormat = '%2d';
ax.YAxis.Exponent = -6;
And the result is: