C/C++ :: Matlab Polyval And Polyder Functions

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


ADVERTISEMENT

C/C++ :: Converting Matlab Struct To Mex

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

C# :: How To Use Code Or Generate DLL In Matlab

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

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 View Related

Visual C++ :: Vector To Matrix MATLAB

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

C/C++ :: How To Access Linked List Functions From Stack Class Without Functions

Mar 20, 2014

I'm a little confused by my programming assignment this week. I've been working at it Wednesday and I've made progress but I'm still confused as to how I'm supposed to do this. The class I made is called Stack, and it's derived from a template class called StackADT. We also utilize a class called unorderedLinkedList, which is derived from a class called linkedList.

We're supposed to implement all of the virtual functions from stackADT in the Stack class. The Stack data is stored in a an unorderedLinkedList, so what I'm confused by is how to implement a few of the Stack functions because there are no functions in unorderedLinkedList which we could call to manipulate the data.

As you can see from my attached code, I'm really confused by how I'm supposed to implement the pop() and top() functions, and I also think my initializeList() function is wrong. We don't have any similar functions in unorderedLinkedList to call, so I'm at a loss of how i'd access my unorderedLinkedList. My initial thought was to call the similar functions in the class that unorderedLinkedList was derived from, linkedList, but I'm unsure of this is what we're supposed to do, or if theres actually a way to access my unorderedLinkedList without having to use the functions from the base class.

NOTE: We're not allowed to modify stackADT, unorderedLinkedList, and linkedList.

Stack.h

#include "stackADT.h"
#include "unorderedLinkedList.h"
template<class Type>
class Stack: public stackADT<Type>{
template <class T>
struct nodeType
{
T info;
nodeType<T> *link;

[Code]...

View 3 Replies View Related

C/C++ :: Array Of Functions Pointing To In Class Functions With Arduino

May 3, 2013

At the moment im trying out with pointing to an array of functions. I got this working as following:

typedef void (* functionPtr) ();  
functionPtr functions[2][2]={{do11,do12}, {do21,do22}};    
void do11(){DEBUG_PRINTLN("11");}
void do12(){DEBUG_PRINTLN("12");}
void do21(){DEBUG_PRINTLN("21");}
void do22(){DEBUG_PRINTLN("22");}    
void loop(){
         A=0;
         B=1;
         functions[A][b]();
}  

But now I'm trying to use this to point to a function inside a class so instead of do11, i want to be able to point to Basic.Do11. Somehow this doesnt work and I keep on getting this message:

error: argument of type 'void (Basic::)()' does not match 'void (*)()'

View 2 Replies View Related

C :: Getting Used To Functions

Jul 24, 2013

So In my studying of C I am starting to come across more programs with functions in them.This particular program asks for two numbers, and calculates the sum of all the squares of the two numbers and the numbers in between them. I am confused about the get_int() function.

Code:

/* checking.c -- validating input */
#include <stdio.h>
#include <stdbool.h>
int get_int(void); // validate that input is an integer
bool bad_limits(int begin, int end, int low, int high); // validate that range limits are valid
double sum_squares(int a, int b); // calculate the sum of the squares of the integers a through b
}

[code]....

So in that get_int() function, it's pretty simple if scanf returns 1, otherwise... another while loop call the getchar() function, which is assigned to the variable ch. So say I enter 'a' for the lower limit, this is what happens:

Code: Enter the limits (enter 0 for both limits to quit):
lower limit: a

a is not an integer. It seems as if getchar() somehow "got the character" from scanf(). There's no way that getchar() could have been simultaneously reading my input, because that function is not even called until scanf has already not returned 1. So I'm confused how that happened. I was under the impression that getchar() got input from the keyboard, which would lead me to think that I would be prompted to input something again when getchar() is called, before putchar() prints the scanf input. But this is obviously not the case.

Also, I'm curious about that comment beside putchar(ch) that says //dispose of bad input. I recall a long time ago on these forums, someone told me something about how once scanf has read input, that input is like... stuck to scanf.. So does putchar() not only print the input from scanf/getchar, but also unload it from scanf, so to speak?

View 4 Replies View Related

C++ :: Get And Set Functions

Feb 1, 2014

i'm stuck with functions

#include <iostream>
#include <functional>
using namespace std;
template <typename T>
class property

[code].....

the code works like a charm. but imagine that i need more with Get and Set functions, how can i connect them to the T PropertyValue on class property?

View 12 Replies View Related

C++ :: How To Get A Set Of Functions To All Use The Same Template

Dec 11, 2013

I'm getting tired of writing Code: template <typename T> everywhere.

Is the only solution to encapsulate all my desired functions in a templated class?

View 7 Replies View Related

C++ :: How To Declare Functions

Aug 19, 2013

How to declare functions in C++

View 1 Replies View Related

C :: Use Of Functions In Top / Down Approach

Mar 25, 2014

I'm getting a bit lost in calling functions correctly. The assignment says to, reprogram this assignment using functions and include the additional features identified below -

Design your program so the main function invokes/calls functions to perform the following tasks:

4) sort the arrays in ascending order by student ID number

Here's what I've got thus far and I'm confused cuz I might be calling my function incorrectly.

Code:
#include <stdio.h>
#define MAX_ENTRIES 50
void s_ID (int student_ID[], int test_score[], char char_val[]);
int main (void) {

[Code] .....

View 7 Replies View Related

C :: Adding New Functions

Jul 3, 2014

I am new to c and I have come across a problem when adding other functions to a programme and printing the values. The question I am attempting to solve is :

The following function computes ex by summing the Taylor series expansion to n terms. Write a program to print a table of ex using both this function and the exp() function from the math.h library, for x = 0 to 1 in steps of 0.1. The program should ask the user what value of n to use.

double taylor(double x, int n) {
int i;
double sum = 1.0;
double term = 1.0;
for (i=1; i<=n; i++) {
/*Or we could have written: */
term = term * x / i; /* term *= x / i; */
sum = sum + term; /* sum += term; */
}
return sum;
}

My code is

Code:

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
/*Taylor series for e*/

[code]....

code prints out the values for exp, but it gets stuck in the Taylor function and I'm not sure how to solve it.

View 2 Replies View Related

C :: Passing Into Functions

Feb 18, 2013

forget everything from before. It came out of confusion regard the supplier functions. dis_s() and read_s() the part functions work and are not any different really.

Code:

#include <stdio.h>#include <stdlib.h>
#include <string.h>
#define MPS 10 //Max Part Size
#define MSS 10 //Max Supplier Size
}

[code]....

when I run the dis_s() function it just prints out garbage until it segments. starts with a bunch of 0 and newlines until it starts printing locations on my computer...... it worked on campus with debian and I only copied it from gmail to my computer so I really don't understand whats up(im on mint).

View 7 Replies View Related

C++ :: Functions Does Not Return New Value

Jul 24, 2014

In my program below, in the getage and get level functions, if an incorrect input is entered, then the correct one is entered after, it still returns the bad input back to main.

#include "stdafx.h"
#include <cstdlib>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>

[Code] ....

View 7 Replies View Related

C++ :: Use A New Class On Functions?

Feb 14, 2015

how use a new class on functions?

class test
{
public:
int a=0;

[Code]....

i did something like these with my image class, but i get wrong results.

View 6 Replies View Related

C/C++ :: Use The Same Variables Between Functions?

Mar 6, 2015

I'm trying to use two variables for two different functions.

#include "stdafx.h"
#include <iostream>
#include <cstdlib>

[Code].....

Every time screen2() runs it always outputs "Numbers entered were 0 and 0". I want the numbers that were entered in by the user in screen1() to be displayed.

View 2 Replies View Related

C/C++ :: Functions Are Undefined?

Sep 20, 2014

Not quite sure what the problem is here. I have all my functions in my class header file, and I believe I have them declared at the top, but it is telling me that I do not. The project is simply to use set and get functions to display the date.

#include "stdafx.h"
class Date
{
public:

[Code].....

View 5 Replies View Related

C# :: Using Mathematical Functions

Dec 5, 2014

like other programmers I am also new to the world of programming. So, I have to use a mathematical function in Cmath.

The function is z1 = Sin2α + sin5α - Sin3α / cosα+1-2sin*2(2α)

z2= √x*3 + 3 / x*3 - 3
My results so far...

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

[Code].....

View 6 Replies View Related

C++ :: Including Outside Functions Into Classes?

Mar 6, 2015

I have a hpp file with a list of inline finctions like this:

Code:
inline int check() {
return 1;
}
inline int check_1() {
return 1;
}

... What I would like to do is to include them into several unrelated classes. How can I do this. Can I just add the hpp inline functions in headers of my class containing files or not. I mean if they are not defined as class functions how can they be called. I don't understan the logic.

View 2 Replies View Related

C++ :: Printing Text With Functions

Feb 27, 2014

Any way to make a function that prints something. i wanted to make a function for

Code:

cout << " PAUSE MENU " << endl; cout << " 0. Resume Game " << endl;
cout << " 1. Commands " << endl;
cout << " 2. Controller Setup " << endl;
cout << " 3. Bottles of Beer " << endl;
cout << " 4. Quit " << endl;
cout << " What is your Choice - ";
cin >> userinput;

So i wouldn't have to retype it again in the loop, i would just call the function. but it seems whatever i try it doesn't display the text. i've tried making a function with no return time like this " Void Pausemenu(); " but that just goes blank.

Code:

#include <iostream>
using namespace std;
//This function displays different results based on the users input
int menu(int menuchoice);
int main()

[Code] ....

View 4 Replies View Related

C++ :: Unicode And Win32 API Functions

Aug 11, 2014

You told me that it's better to use UNICODE all the time.

What if the Win32 Api function doesn't have a UNICODE version.

For example CryptProtectData() takes a BYTE (DATA_BLOB *) which is an unsigned char?

[Code] ......

View 7 Replies View Related

C :: Functions With Different Return Type?

Feb 26, 2015

understand the below program.

Why I'm getting output y is 6.000000

Code:
#include <stdio.h>
int square(double a);
int main()

[Code].....

View 6 Replies View Related

C :: Passing Arguments To Functions

Feb 4, 2013

Having a little trouble passing arguments to functions.

I wrote this simple program to get the hang of it but I'm quite stuck. I'm sure you will be able to get at what i want the program to do...

Code:
#include <conio.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <windows.h>

void menu(int HP,int Gold,int Armour);

[Code] ....

View 3 Replies View Related

C :: How To Pass Arrays To Functions

Sep 23, 2014

I have read about it in my book and also on this website but i still have things uncleared....

View 11 Replies View Related

C :: Difference Between Two Int Main Functions

Feb 6, 2014

I just wanted to know what's the difference between these two types of main functions:

Code: int main (int argc, char** argv){ ... }

Code: int main (int argc, char* argv[]){ ... }

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved