Hello,
I have two codes here. Matlab code is the reference code and I have written this C++ code from that.Don’t worry about the values because i just want to know if the logic of the C++ code is same as MATLAB code coz I am getting some incorrect values as output. However I have declared a few values so that u get some clue of its datatype.
Promptcode, earlycode and latecode each has a random combination of +/- 1’s.
Cacode...
User Profile
Collapse
-
Verify the two codes please...
-
int *x=new int[38200]; is this correct??
Hello,
I have done the following initialization in my C++ code:
int *x=new int[38200];
However a doubt arouse to me now..... int can take values only from 2^15 to (2^15)-1..........So do i have to change it to something like
long int *x=new long int[38200] or is it ok coz its allocating dynamic memory?? If I have to change, then what should it be i.e is my new initialization correct?
Thanks,
prads -
For loop not executing enough times.
hello,
this pgm of mine should loop codeperiod(3700 0 in this case) no. of times. However its doin it for just 3 times. Pls help. Also i think there is an exception arising somewer in my pgm nd i need to write a try-catch but dont know wat statements to write within tat. Somebody pls help me out.
Thanks,
prads
Code:for(loopcnt=0;loopcnt<codeperiods;loopcnt++)// what is codeperiods..37000 ???
-
im sorry but didnt understand a word!!! :) -
Output Window flashes and closes
Hello,
Though I have given getchar(); at the end of my C++ program, it displays the output but the cmd window just flashes and closes immediately. It is a huge pgm of abt 500+ lines and deals with a lot of data. So can anyone tell me how i shud retain the cmnd window so that i can know my output?? I also tried system("pause") ; but with no help. Pls tell me what has to be done?
Thanks,
prads -
oh!...so is there any way out......i.e any other cmnd tat works well with .bin files....Leave a comment:
-
Incorrect length output in File read in C++
Hello,
The pgm below opens a file, reads it and displays the contents and its length.
However it displays a length of (length+2) and also the samplesread as (samplesread +2), where samplesread is the length obtaines from gcount(), and length from tellg(). Pls tell me how i should get the correct length and samplesread??. Also if i enter the data in my file in the next line, it considers "\n" towards the length count. Pls correct... -
I am sorry........li ne 39 in my code corresponds to 18 in the above code. i.e the error is in DEFUN_DLD()
Thanks,
pradsLeave a comment:
-
It shows the foll errors.....
octave/oct.h: No such file or directory.
39 expected constructor, destructor, or type conversion before '(' token
39 expected `,' or `;' before '(' token
Thanks,
PradsLeave a comment:
-
struct redeclare problem
hello,
i have a struct and have declared it as shown below. If i print its value in the main() fn it prints it correctly.Howev er if i declare the struct again in the main() and try to print its value it doesnot give me the correct value but prints some garbage value. Why is it so? Is there any way to correct it because i think i have to declare it again in main() for initializing other variables.
thanks,
prads
... -
output error while displaying read file!
Hello, the foll pgm displays some wierd looking characters at the output when cout<<buffer<< is done. Pls tell me why it happens and also correct the error.
Thanks,
Prads
[code=cpp]
int main ()
{
int length;
char * buffer;
size_t samples_read;
ifstream is; //is is the fid
is.open ("C:\\t1.txt ", ios::binary );
//...Last edited by sicarie; Nov 5 '07, 05:25 PM. Reason: Code tags are [code=cpp] code goes here [/code]. Please use them -
Transpose of a non-square matrix
Hello,
Can anybody tell me how i shud go about to perform the transpose of a nonsquare matrix array. Pls give me an idea so that i can write one based on that and then post queries if errors r found. Say i have an array a[10] whose transpose is reqd?
Thanks,
Prads -
waitbar function error. Pls help
Hello,
this waitbar function (similar to the one in matlab) in C++ pops an error. Pls correct the error for me.
Thanks,
prads
[code=cpp]
<code>
#include <octave/oct.h>
#if defined (HAVE_TERM_H)
# include <term.h>
#elif defined (HAVE_TERMCAP_H )
# include <termcap.h>
#endif
#define BUF_SIZE 256
#define MAX_LEN 240...Last edited by weaknessforcats; Nov 4 '07, 04:09 PM. Reason: Please use [code=cpp] or [code=c] and [/code] tags -
Hello,
I am writing a C++ program for tracking of GPS signals using matlab code as reference. I came across these lines in the code and wondered if i cud do it in C++ as well.......henc e the question....Pls let me know how to do th same...
Thanks,
PradsLeave a comment:
-
File Open and Read in C++
Hello,
The C++ pgm below opens a file, reads it and displays what is read. However at the end of the output it also appends some crazy looking characters. Pls correct it for me.
Thanks,
Prads
<code>
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main ()
{
FILE * pFile;
long lSize;
char... -
C++ equivalent of matlab
Hello,
I want to write the following matlab code lines in C++. Somebody pls help me...
and one more basic question.....wh at is C++ equivalent of matlab fid...is it
rawsignal in:
file_op.getline (rawsignal,blks ize);
Thanks,
Prads
<code>
1) fseek(fid,5,'bo f');
2) try
waitbar(loopCnt/codePeriods, ...
hwb, ...
['Tracking: Ch ', int2str(channel Nr),... -
waitbar function error
Hello,
I found this waitbar functioning pgm in a forum which does the same work as a matlab waitbar. However this pgm has an error and i cudnot figure it out. Can anyone pls correct it.
Thanks,
Prads
[code=c]
/*************** *************** *************** *************** **************
* Waitbar function -- displays progress of lengthy calculations
* -------------------------------------------------------------... -
-
I am sorry but I couldnot understand much from that and with whatever I interpreted, I couldnot get the output. So can u pls make the required changes to my program and post it..
thanks,
prads...Leave a comment:
-
Function not returning correct values
Hello,
the following code doesnot return the corect values to the main function. However it prints the correct values within the function. Also the same when written in C works absolutely fine. Pls tell me where im going wrong and correct me. U can run it and check!
Thanks
Prads
[code=cpp]
#include <iostream>
#include <fstream>
#include <cstring>
#include <cmath>...
No activity results to display
Show More
Leave a comment: