Respondida
matlab engine giving wrong result when called in a function in Cpp file
These lines: int call_matlab_processing(double double_array[], int size_double_array,double * sorted, double * indices_cpp)...

más de 10 años hace | 0

| aceptada

Respondida
can we use matlab engine from a inside a function in C++
You have a fundamental flaw in your code. You free the memory behind the pointers that you use downstream in your code. E.g., ...

más de 10 años hace | 0

| aceptada

Respondida
Problem With K2 Algoritm
The message you are getting indicates that MATLAB can't *find* the function. Check your path to see that this function is in a d...

más de 10 años hace | 0

| aceptada

Respondida
??? Error using ==> mtimes Inner matrix dimensions must agree. Error in ==> Untitled2 at 16 l0=[(x-15)*(x-25)*(x-35)*(x-45)]/240000;
Change the matrix operator * to element-wise operator .* E.g., x=(0:1:40); l0 = ((x-15).*(x-25).*(x-35).*(x-45))/240...

más de 10 años hace | 0

Respondida
Newton method calculations using loops??stuck!!
You are close. You need to get the result of your NewtonMethod call into the variable rn so you can do the comparison. You also ...

más de 10 años hace | 0

Respondida
How do I get values of for loop into a vector?
Is there some reason you want or need to use a loop for this? E.g., using vectorized code your inner loop can be reduced to this...

más de 10 años hace | 0

Respondida
Use BLAS library in C Mex-File
You need to use the correct integer types for BLAS/LAPACK calls. E.g., mwSignedIndex one = 1; // <-- Or ptrdiff_t one ...

más de 10 años hace | 1

| aceptada

Respondida
How do I use ode45 properly? (Syntax related)
The first argument to ode45 is supposed to be your derivative function. You are attempting to pass in a matrix in this spot (and...

más de 10 años hace | 0

Respondida
How to use cgs with your own matrix-vector multiplication?
If a,c,d are pre-existing constant terms, you could use an anonymous function. E.g., afun2 = @(b)(afun(a,b,c,d)) then ...

más de 10 años hace | 0

| aceptada

Respondida
(x" + sin(x) = 0). Use MATLAB’s ode45 solver to generate a numerical solution of this system over the.i nee the function w = f(t,x), x =z(1) and the code for w in order to solve the IVP
Some hints: Turn this single 2nd order equation into two 1st order equations. E.g., define a 2-element vector y (or some othe...

casi 11 años hace | 1

Respondida
How does matlab provide precise Taylor expansions for some truncation order?
Not sure what you are really asking here. There is a taylor function in the Symbolic Toolbox that does such expansions for whate...

casi 11 años hace | 0

Respondida
Need Help making a nxn symmetric matrix
Making a guess at what you really want, you could build it in pieces, e.g., n = size of matrix; A = zeros(n); A(1:n+1...

casi 11 años hace | 0

| aceptada

Respondida
I am trying to create an array that displays the values 1-25 and puts the correct calculation next to it
You could move the fprintf *inside* the loop, just before the "end" statement. E.g., fprintf('%2d %d\n',i,A(i)); %%% Print...

casi 11 años hace | 0

Respondida
How can I find the index and value of the smallest element within a range of values in a vector
You could add code to map the index back into the original vector. E.g., rangeTestVals = testVals>loVal & testVal<hiVal; ...

casi 11 años hace | 0

Respondida
How to define function to work on any double array
The error message you are getting is typical when MATLAB can't *find* the function. Check your path to ensure that the file test...

casi 11 años hace | 0

| aceptada

Respondida
how to define if or for for the following question
xy = [x;y]; minxy = min(xy); maxxy = max(xy); g = x - y < 0; d = x; d(g) = maxxy(g); d(~g) = minxy(~g);

casi 11 años hace | 0

| aceptada

Respondida
Function with Multiple Outputs
You can call it like this: [~,n] = fun(x);

casi 11 años hace | 0

| aceptada

Respondida
Integrating experimental acceleration data to get velocity and position
Can't you just do an accumulated sum on the acceleration (with appropriate scaling) to get velocity, and then an accumulated sum...

casi 11 años hace | 0

Respondida
Error: Subscript indices must either be real positive integers or logicals.
E.g., in these lines: x(1i)=1.236; y(1i)=0.0734; 1i is the imaginary number sqrt(-1) ... it is not a valid value to u...

casi 11 años hace | 0

Respondida
Unexpected MATLAB expression in MATLAB
This line uses the _function_ keyword, which means you are starting a function definition: function [F, V, N] = read_stl_fi...

casi 11 años hace | 1

| aceptada

Respondida
Is there any way we start with all ones vector of length 10 and need to increment it in steps till we have a vector of length 10 with each element equal to 30
Start with: v = [1 1 1 1 1 1 1 1 1 1 ]; Then for each increment do this: v = v + 1;

casi 11 años hace | 0

Respondida
"Insufficient number of outputs from right hand side of equal sign to satisfy assignment."
You likely have inadvertently created a variable named "min" in your code, which is shadowing the function min. Go find that var...

casi 11 años hace | 25

| aceptada

Respondida
Get the row index of matrix where the first 3 columns are equal in two matrix
Assuming the match is always in the first three columns (caution, untested): k = ismember(A(:,1:3),B,'rows'); D = A(k,:)...

casi 11 años hace | 0

| aceptada

Respondida
find rows of two matricies (of different sizes) based on matching element of one column
Caution, untested: k = ismember(A(:,4),B(:,4)); C = A(k,:);

casi 11 años hace | 0

Respondida
How do I sort the rows in one array based on the row order of another array?
Try this (Caution, untested since I am not on a machine with MATLAB at the moment): [~,Locb] = ismember(New_C,C,'rows'); ...

casi 11 años hace | 0

| aceptada

Respondida
Where am i going wrong in this "for loop" script associated with the question below? See the script below the question:
You are missing the "for" key word: for x= 0:5:100

casi 11 años hace | 0

| aceptada

Respondida
mexCallMATLAB Memory Leak / mxDestroyArray / C++ Crashing
Some comments: 1) The signature for mxCreateNumericArray shows the dims argument as being mwSize, not mwSignedIndex. So this ...

casi 11 años hace | 2

| aceptada

Respondida
uses of 'zeros' and 'ones' function ?
A couple of examples. zeros is often used to allocate a variable to a known size, then downstream code will fill in the indiv...

casi 11 años hace | 1

| aceptada

Respondida
How can I make called my function stay in the memory so it can be efficiently run in loop?
The first time you call a function it is parsed and put into memory. It will subsequently stay in memory unless you do somethin...

casi 11 años hace | 0

Respondida
Calling LAPACK in MEX files
Some observations: 1) You are using mwSize for the type of integer to use for the LAPACK arguments. Don't do this since this...

casi 11 años hace | 1

| aceptada

Cargar más