main.cpp
#include <fstream>
std::ofstream fout("..//result.txt");
//std::ofstream fout("C:\\Users\\alan\\Desktop\\result.txt");
fout << x << " " << y << " " << z << std::endl;
fout.close();
Ploy.m
clear;
clc;
figure(1)
data=dlmread("result.txt")';
plot(data(1,:),data(2,:),'b-');
hold on;
plot(data(1,:),data(3,:),'g-');
hold on;
plot(data(1,:),data(4,:),'r-');
hold on;
grid;%网格
title("Title");
xlabel("x ( s )");
ylabel("y ( m / s^2 )");
legend('x','y','z');