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;
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] .....
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?
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;
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 (*)()'
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?
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) {
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.
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.
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).
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.
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.
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.
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.
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()