how to plot these 2 column data into a curve on oxy plane

56 views (last 30 days)
pls see the attached,
Thanks &Br,
Shawtone

Accepted Answer

Umar
Umar on 3 Jan 2026 at 22:20

Hi @晓通,

I saw your question about plotting 2-column data as a curve on the Oxy plane. I've tested a solution with your matlab_data.mat file and it works perfectly in MATLAB Mobile.

The Oxy plane refers to the XY coordinate plane where z=0. For plotting 2-column data as a curve, the standard plot function is the most appropriate choice rather than fsurf, which is designed for 3D surface plotting.

Here's the complete code that works with your data:

close all;clear all;clc
% Load data from MATLAB Drive
loaded_data = load('/MATLAB Drive/matlab_data.mat');
% Access the table from the struct
T = loaded_data.T;
% Extract the two columns from the table
x_data = T{:,1};  % First column
y_data = T{:,2};  % Second column
% Plot the curve on the Oxy plane (XY plane)
figure;
plot(x_data, y_data, 'b-', 'LineWidth', 2)
xlabel('X')
ylabel('Y')
title('Curve on Oxy Plane')
grid on
axis equal  % Equal scaling for both axes
% Optional: Add markers to show data points
hold on
plot(x_data, y_data, 'ro', 'MarkerSize', 6, 'MarkerFaceColor', 'r')
hold off
legend('Curve', 'Data Points', 'Location', 'best')

Results: please see attached.

The code handles your data structure correctly. Your mat file contains a struct with a 100x2 table named T, so the code first loads it into a variable, extracts the table, then gets both columns using the table indexing syntax T{:,1} and T{:,2}.

The resulting plot shows your data as a blue curve with red markers at each of the 100 data points. The curve has an interesting wave-like pattern that creates a figure-eight shape with oscillations. The axis equal command ensures both axes use the same scale, which gives you a true geometric representation of your data on the XY plane.

This solution is optimized for MATLAB Mobile and provides clear visualization of your 2-column dataset as a continuous curve on the Oxy plane.

More Answers (1)

Chuguang Pan
Chuguang Pan on 3 Jan 2026 at 7:50
load matlab_data.mat
plot(T.x,T.y,'o--');
title(string(ans))

Community Treasure Hunt

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

Start Hunting!