How to create a Mex File out of C++ Code

3 次查看(过去 30 天)
Hello all,
I have an old C++ code that calculates Bowling scores for four people and I was hoping someone could teach me how to use the mex function. I am using Windows XP. My code is as follows.
#include <mex.h>
#include <iostream>
#include <cmath>
using namespace std;
int main(void) {
int score1 = 0,score2 = 0,
frame = 1,
total[4],bowler[4];
bool lastwasstrike[4] = {false, false, false, false},
last2strike[4] = {false, false, false, false},
lastwasspare[4] = {false, false, false, false};
for (frame=1,frame<=10,frame++){
for (int i=0,i<=4,i++){
cout << "Enter next bowler's score ";
cin >> score1;
total[i] = total[i] + score1;
if (last2strike[i] = true){
total[i] = total[i] + score1;
last2strike[i] = false;
}
if (lastwasstrike[i] = true)
total[i] = total[i] + score1;
if (lastwasspare[i] = true){
total[i] = total[i] + score1;
lastwasspare[i] = false;
}
if (score1 < 10){
cout << "Enter second score for this frame ";
cin >> score2;
total[i] = total[i] + score2;
if (lastwasstrike[i] = true){
total[i] = total[i] + score2;
lastwastrike[i] = false
}
if (score1 + score2 == 10){
cout << "Spare! ";
lastwasspare = true;
}
else {
cout << "Strike!!! ";
if (lastwasstrike[i] = true)
last2strike[i] = true;
lastwasstrike[i] = true;
}
cout << total[i];
}
}
cout << "Game Over, final scores " << total[0] << " " << total[1] << " " << total[2] << " " << total[3];
return 0;
}
When I try entering mex project2a.cc into the command window it says
C:\PROGRA~1\MATLAB\R2012B\BIN\MEX.PL: Error: 'project2a.cc' not found.
If anyone could help me I would greatly appreciate it. Thank you!

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Compiler 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by