Hello everyone,
I have the following arrays: spatial_grid(30001×1 elements), physical_time_elastic (2431×1 elements), and data_set_elastic (30001x4x2431 elements). What I want to is to plot a something like the figures that appears here: https://blogs.mathworks.com/steve/2016/04/25/clim-caxis-imshow-and-imagesc/. In my case, the x-th axis will be spatial_grid, the y-th axis the physical_time_elastic array, and the magnitude that will be encoded by colors will data_set_elastic (:,2,i), where i runs over the elements of physical_time_elastic (note that length(physical_time_elastic)=2431, as the number of elements of data_set_elastic in the third dimension). For each i, therefore, I have the value that corresponds to (spatial_grid, physical_time_elastic). What I have tried to do is the following, but it does not work:
outputdir='Figures';u1=figure(1)for i=1:length(physical_time_elastic) image(spatial_grid.*(10^6),physical_time_elastic(i).*(10^(12)),data_set_elastic(:,2,i))endcolormap jet; axis xy;clr1=colorbar;xlabel('Track position, $x \, \, \left( \mu\mathrm{m} \right)$','FontSize',14,'interpreter','latex')ylabel('Time, $t \, \, \left( \mathrm{ps} \right)$','FontSize',14,'interpreter','latex')ylabel(clr1,'$m_x$','Interpreter','Latex','FontSize',14);t1=title('Elastic scattering, $w_{1,2}=1/2$','FontSize',14,'interpreter','latex')set(t1,'interpreter','latex','FontSize',14)set(gca,'TickLabelInterpreter','latex','FontSize',14)set(u1,'Units','Inches');posu1=get(u1,'Position');set(u1,'PaperPositionMode','Auto','PaperUnits','Inches','PaperSize',[posu1(3),posu1(4)])saveas(gcf,fullfile(outputdir,['In-Plane_Magnetization_Distribution_Elastic_Scattering.pdf']))
Any idea? I have attached a sample of what I get. The values that appears in the colorbar are completly wrong, because the variable that it is encoded in the color has values between -1 and +1. Also the track position begins in 0 and goes to a value like 3000, increasing its value linearly.
Best Answer