MATLAB: Plotting Reaction Spectra over Time

3d plotsgstoolsMATLABspectroscopy

I have imported a series of x,y data in a table that vary over time that visualizes a reaction using spectroscopic data. I would like to plot these x,y data in a 3D figure with respect to time, which is labelled as zvalue within the spectra tree of the variable "Specdata" in the attached file. I am also unable to plot all of the x,y data as a group in a 2D figure, but have been able to achieve a single spectra plot using :
plot (Specdata.spectra(x).xaxis, Specdata.spectra(x).data)

Best Answer

Try this:
D = load('3D Spectra Plot.mat');
F = fieldnames(D.Specdata.spectra);
C = squeeze(struct2cell(D.Specdata.spectra));
x = cell2mat(C(4,:)');
y = cell2mat(C(5,:)');
z = cell2mat(C(1,:)');
zm = z * ones(1,size(x,2));
figure
plot3(x, y, zm)
grid on
xlabel(F{4})
ylabel(F{5})
zlabel(F{1})
view(135, 35)
Experiment to get the result you want.
Plotting Reaction Spectra over Time - 2019 04 27.png