How to plot arbitrary line slice against x or y axis in a table?
Afficher commentaires plus anciens
I have a data in a regular grid with x and y axis. I would like to extract any line slice of the data taken along x axis (in between two user defined y values) and plot it with respect to the appropriate x axis.
data = rand(5, 5);
x_axis = [5 6 7 8 9];
y_axis = [10.1 10.2 10.3 10.4 10.5]';
%Adding the x and y axis to the data
dataWithAxes = array2table(data,'VariableNames',string(x_axis), 'RowNames',string(y_axis));
% slicing the data for y = 10.1 in between x = 5 and x = 8
x_start='5'; x_end='8';
[X,Y] = ismember({x_start,x_end},dataWithAxes.Properties.VariableNames);
sliced_data = dataWithAxes('10.1',Y(1):Y(2))
How do I plot the sliced_data with its x values (which is [5 6 7 8])? I do not want to call the variable 'x_axis' as the axis information is already there in the variable 'sliced_data' and 'dataWithAxes'. Please suggest a soultion. Thank you.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Line Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
