필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
Nicholas
Nicholas 2013년 7월 2일
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