#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
// Function to generate automatic legend in MATLAB format
string generateMatlabLegend(const vector<string>& dataNames) {
string legend = "legend(";
for (const string& name : dataNames) {
legend += "'" + name + "', ";
}
// Remove the trailing comma and space
if (!dataNames.empty()) {
legend.erase(legend.size() - 2);
}
legend += ");";
return legend;
}
int main() {
// Example usage
vector<string> dataNames = {"Data1", "Data2", "Data3"};
// Generate MATLAB legend string
string matlabLegend = generateMatlabLegend(dataNames);
// Display the generated legend
cout << "Generated MATLAB Legend:\n" << matlabLegend << endl;
return 0;
}