C++ :: Error When Translating Function From Matlab To C
Jul 1, 2013
I have en error translating a function from Matlab to C/C++ :
Code:
radius(floor(rows/2+1),floor(cols/2+1)) = 1;
% Get rid of the 0 radius value at the 0
% frequency point (now at top-left corner)
% so that taking the log of the radius will
% not cause trouble.
What I did is:
Code: radius[rows/2][cols/2]=1;
I m sure it s there the problem, because before this line I can print what I want and I can see it at run-time, but after this line I can not print nothing and the work is like blocked. Do you know the error?
View 7 Replies
ADVERTISEMENT
Nov 27, 2014
How do I change the following recursive function into a iterator function and basically what should it look like?
int f(int i) {
if(i<2)
return i;
return f(i-2)+f(i-1);
}
View 1 Replies
View Related
Jul 24, 2014
I have a struct that I'm writing in C and need to use a mex function to use it in matlab. The struct was originally in matlab and need to have the variables:
force = feval(forcing, Euler, Euler.x(:,k));
q = squeeze(q(:,k,:)/>/>);
q0 = squeeze(Euler.q0(:,k,:)/>/>);
nx = Euler.nx(:,k);% normal vector
J = Euler.J(1,k);
rx = Euler.rx(1,k);
qh = reshape(qh(k:k+1,:)/>/>,[],1);
k = k;
The mex function I have come up with is:
#include "mex.h"
/* Extract local info for element k */
/* local struct */
typedef struct {
double force;
double q;
[Code] ....
View 2 Replies
View Related
Feb 20, 2014
I have an application thats has been coded in C#. After build it generates a standalone dll file and the exe file.
I want to use this code in Matlab. I found out from this page that I can load the C# classes or codes into Matlab.
dll_in_matlab = NET.addAssembly('location to the dll file)
I have the code and the application buty unfortunately I do not understand C# at all. So after using this command I was able to see a .NET object in my workspace and this is what I got for its properties and its classes:
evmaps =
NET.Assembly handle
Package: NET
Properties for class NET.Assembly:
AssemblyHandle
Classes
Structures
Enums
GenericTypes
[code]....
This is the application it produces: [URL] and here is the virustotal result for my application just to ensure that its clean. [URL] .....
View 1 Replies
View Related
Aug 10, 2014
I am trying to write functions that behave exactly as the polyval and polymer functions do in Matlab. My code is outputting the wrong solution ...
#include <iostream>
#include <cmath>
using namespace std;
float polyval(float*, int, float);
void polyder(float*, int, float*);
[Code] ....
View 5 Replies
View Related
Jul 2, 2013
i have 12 vectors of size 1*150 (1 row 150 columns)
i want to merge all these 12 vectors to a matrix of size 12 *150 (12 row 150 columns)
all vectors are of same size 1* 150 andAll of them have to join into a matrix of size 12* 150
say vectors are (A1 A2 ... A12) TO a single matrix A(size 2 * 150) I AM USING MATLAB
View 1 Replies
View Related
Jul 6, 2014
error says "cannot convert 'int*' to 'int' in function main()
and also
type mismatch in parameter in function sort(int,int)
Heres the code:
#include<iostream.h>
#include<conio.h>
void main() {
void sort(int,int);
clrscr();
[Code] .....
View 11 Replies
View Related
Mar 19, 2013
I searched the web for error: C3867... and the discussions where murky or obscure.
My code excerpt is:
#pragma once
#include <windows.h>
#include <stdlib.h>
#include <process.h>
void PutUpfrmIO(void *);
namespace WordParsor {
[Code] .....
I get the generic message:
error C3867: 'WordParsor::Form1::PutUpfrmIO': function call missing argument list; use '&WordParsor::Form1::PutUpfrmIO' to create a pointer to memberc:userskingc++wordparsorwordparsorForm1.h... and the suggestion fix generate another error.
One person suggested the gcroot<> object wrapper... but I do not know how to modify/declair the function or its argument type.
View 2 Replies
View Related
Jul 2, 2013
I have no error compiling, but running my project it stops before entering a function and debugging I have an error about Segmentation fault. The function:
Code:
1
2
3
4
5
6
7
Mat logGabor(matriz filter,Mat filter,double r_o,double theta_o,double sigma_theta, matriz radius,matriz theta,int cols,int rows,double sigma_r,int *padSize){
[Code]....
View 5 Replies
View Related
Jul 2, 2013
I have no error compiling, but running my project it stops before entering a function and debugging I have an error about Segmentation fault. The function:
Code:
Mat logGabor(matriz filter,Mat filter,double r_o,double theta_o,double sigma_theta,
matriz radius,matriz theta,int cols,int rows,double sigma_r,int *padSize){
Mat rpad;
int k=*padSize;
printf("Welcome to the function"); //Here the error
...
More info: I created the matriz as : typedef double** matriz;
and a createmat function that give back a double** and in this function I allocate space for matriz and works. In the main:
Code:
Mat chr-Rpad[4][5]; //chrOrient=4;chrScales=5
for(int i_or=1;i_or<chrOrient;i_or++){
for(int i_sc=1;i_sc<chrScales;i_sc++){
//some math calculation
chrRpad[i_or-1][i_sc-1]=abs(logGabor(filter,imftt2,r_o,theta_o,sigma_theta,radius,theta,cols,rows,sigma_r,padSize));
View 6 Replies
View Related
Aug 25, 2014
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main() {
int i=1,j=2;
float k,l=1.5;
[Code] ...
View 3 Replies
View Related
Sep 12, 2013
I'm new to C/C++. I'm trying to make a program that's going to use the CBLAS libraries that I downloaded on BLAS. After fighting tooth and nail with VC 2005 (I downgraded on purpose because at one point I was desperate.) with regards to solving compilation errors and such and eventually it all compiled just fine.
The problem now is, I get the above mentioned error. It says: "Unhandled exception at 0x0040271c in Try.exe: 0xC0000005: Access violation reading location 0x4e18feb8."
Now there are a few .cpp files (I'm compiling as C code.) which contain the functions and there is one other one which contains my main method. Using the debugger, it goes through 3 files all in all.
The main file: Code: /* cblas_example2.c */
#include <stdio.h>
#include <stdlib.h>
#include "cblas.h"
#include "cblas_f77.h"
[Code] .....
I get the above-mentioned exception in the last line, or:
Code: cblas_dgemm( UNDEFINED, transa, transb, *m, *n, *k, *alpha, a, *lda, b, *ldb, *beta, c, *ldc );
The debugger tells me what the address in the exception is the address if *ldc.
View 6 Replies
View Related
Apr 29, 2014
I'm working through the Let us C book. One exercise asks me to collect int and float , then pass them to a function that gets product of these and returns it to main. My code looks like this:
Code:
#include <stdio.h>#include <stdlib.h>
main()
{
int a;
float b, c;
[Code]...
So while compiling i get an error about conflicting types for product. I tried to google that error but couldn't understand what's the problem. My only clue is that i can't pass int and float to a function at the same time... Could that be it?
View 6 Replies
View Related
Dec 13, 2013
I'm using a library in my code in a file called "my_signal.c". In this file I've defined this function:
Code:
Sigfunc * signal(int signo, Sigfunc *func){
struct sigaction act, oact;
...
}
Since the signal function is also in file signal.h and I included it in "my_sygnal.h" file, I'm wondering why the compiler did not say anything about this "double declaration" of the function with the same name.
View 9 Replies
View Related
Nov 6, 2013
THis is my small program i am getting error CPP 46: 'result::putdata()'is not accessible
#include<iostream.h>
#include<conio.h>
class stud
{
[Code]......
View 1 Replies
View Related
Apr 8, 2014
double expression(int n, double x) {
double num=(pow((x),2*a));
double den=fact(n,a);
double sum=0;
for(int a=0; a>=0; a++)
sum=pow(x,n)*(num/den);
return sum;
}
I don't know why this isn't working. fact is a factorial function which I have tested and it works fine. But when I input, for example:
int main() {
cout<<expression(1,3)<<endl;
getch();
return 0;
}
it comes up with an error.
View 5 Replies
View Related
Nov 19, 2013
I am currently working on a code, but I keep getting a error as follows:
[Linker error] undefined reference to 'getHoursOfTheWeek(double)'
[Linker error] undefined reference to 'getGrossPay(double)'
[Linker error] undefined reference to 'getStateTax(double)'
[Linker error] undefined reference to 'getFederalTax(double)'
[Linker error] undefined reference to 'getFICA(double)'
[Linker error] undefined reference to 'getWithHoldingAmount(double)'
I have been trying to debug this error for hours and I am completely stumped....
//BEGIN
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
string getUserName();
double getPayRate();
[Code] .....
View 2 Replies
View Related
Nov 23, 2014
I'm trying to pass an 2d array to a function, but i'm getting this error message:
Error: 'p' undeclared here (not in a function)
#include <stdio.h>
void regStock(int stock[][p], int a);
int main( ) {
int a, p;
scanf("%d", &a);
scanf("%d", &p);
[Code] .......
View 6 Replies
View Related
Dec 14, 2013
This code from [URL] as it is gives compile error I can't understand.
#include <iostream>
using namespace std;
class Rectangle {
int width, height;
[Code] ....
Gives error
(g++ first.cpp)
first.cpp: In function ‘int main()’:
first.cpp:14:38: error: no matching function for call to ‘Rectangle::Rectangle(<brace-enclosed initialiser list>)’
View 3 Replies
View Related
Mar 5, 2014
template <class T>
void Arreglo<T> :: Registro (ifstream& Entrada) {
Entrada >> Cantidad;
Dealer = new T [Cantidad];
for (int i = 0; i < Cantidad; i++) {
[Code] .....
It says the following error when I comile it:
error: expected type-specifier before 'Detail'
(*(Dealer + i)).Modelo = new Detail[(*(Dealer + i)).AmountModels];
error: expected ';' before 'Detail'
View 3 Replies
View Related
Apr 9, 2013
I am creating code for a group project in my class. All my group members made a header file with an object in it with their functions. One of the functions in my partner's code uses a data member of mine in the function, so she has the function parameter a object of my object. (This isn't the code but for example)
class B {
friend class A;
void displayAthing(A object) {
cout<<object.thing<<endl;
}
I have this when I call the function in the cpp file
int main() {
A object;
B b;
b.displayAthing(object);
return 0;
}
However, when I compile, it gives me an error that the function does not take 1 arguments.
View 4 Replies
View Related
Mar 16, 2015
I'm getting an undefined reference error to a function, and I can't figure out why. I have tried letting code blocks compile the files, I have tried the command line to compile it with the same results.
I looked up the error and found this from [URL]
undefined reference
Example
/tmp/cc2Q0kRa.o: In function `main':
/tmp/cc2Q0kRa.o(.text+0x18): undefined reference to `Print(int)'
collect2: ld returned 1 exit status
Meaning / Your code called the function Print, but the linker could not find the code for it in any .o file
Usual Causes
You forgot to link the .o file that contains the function
You misspelled the name of the function
You spelled the name of the function correctly, but the parameter list is different in someway
which seems to be the error I get. I have double checked all 4 and I see nothing.
The code that specifically gives me the error is:
Item *name = new Item(desc, id, weight, loc);
itemMap.addItem(name);
and the class looks like this:
class Item // Standard Items {
private:
std::string name;
std::string desc;
int id;
int weight;
int loc;
[code].....
I think everything matches up unless I'm just missing it.
Full codes are located here: [URL]
what I'm doing wrong?
View 5 Replies
View Related
Nov 23, 2014
I'm working on a short program to calculate the mode of a vector of ints. I am new, so not extremely familiar with pointers, and passing items to functions. This is something I've struggled with (obviously, or I wouldn't be here). I am currently getting the following error when I try to compile this program using g++:
warning: pointer to a function used in arithmetic
I receive this error for the following lines: 66, 73, 75, 81.
I am not using pointers here so I do not understand why this error crops up, much less how to fix it. Here is the code I am struggling with:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <limits>
using namespace std;
vector<int> getModes(vector<int> userValues);
[Code] ....
The errors are on lines 54, 61, 63, and 69
View 3 Replies
View Related
Mar 8, 2013
I wrote a binary function based on existing template:
template <class T> struct percentage : binary_function <T,T,double> {
double operator() (const T& x, const T& y) const
{return x*1.0/(x+y);}
};
I call it in form of percentage<int>() When I compile, it's indicated: error C2143: syntax error : missing ',' before '<' I use VC 2012.
View 5 Replies
View Related
Sep 24, 2014
i was working to compile the code below. Unfortunately it didn't compile and give me the known error error: attempt to use poisoned "calloc".
This is how i compile it :
gcc -I/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/plugin/include -fPIC -O0 -Wall -pedantic -std=c99 -c decode.c decode.o
decode.c
#include <stdio.h>
#include <coretypes.h>
#include <gcc-plugin.h>
#include <gimple.h>
#include <tree.h>
[code]....
View 1 Replies
View Related
May 22, 2013
#include<iostream.h>
#include<conio.h>
int main() {
setcolor(BLUE);
setbkcolor(yellow);
cout<<"the text in blue colour with yelow background";
getch();
return 0;
}
it keeps returning the same error always in my turbo c++ compiler . What is the correct program for changing background colour and text colour ...
View 1 Replies
View Related