Converting C++ to Matlab code!
古いコメントを表示
Can anyone be able to help me convert the C++ code below to Matlab code???
#include<iostream>
#include<cstdlib>
#include<fstream>
#include<cmath>
using namespace std;
int main() {
double *val = new double[56];
cout << "\nReading values from 'xxxx3padata.txt' file.....\n";
ifstream input;
input.open("xxxx3padata.txt");
if (!input) {
cout << "\nError! cannot open file";
exit(0);
}
for (int i = 0; i < 56; i++)
input >> val[i];
input.close();
double Ra = 0, Rq = 0, Rm = 0, max = 0, min = 0;
for (int i = 0; i < 56; i++) {
if (val[i] < min)
min = val[i];
if (val[i] > max)
max = val[i];
Ra += fabs(val[i]);
Rq += pow(val[i], 2);
}
Rm = max - min;
cout << "\nThe arithmatic mean value of the measurements is: " << Ra / 56 << " microns\n";
cout << "\nThe root mean square average of the measurements is: " << sqrt(Rq / 56) << " microns\n";
cout << "\nThe maximum roughness height of the measurements is: " << Rm << " microns\n";
delete []val;
return 0;
}
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で MATLAB Support for MinGW-w64 C/C++ Compiler についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!