답변 있음
Could I pass a 'triangulation' class into mex?
triangulation is a classdef OOP class. You cannot use struct API functions such as mxGetField( ) to get at the properties. You...

18일 전 | 0

| 수락됨

답변 있음
How to convert simple multiplication of variables into dot(.*) multiplication
You could use this https://www.mathworks.com/help/matlab/ref/vectorize.html although current doc says it is not recommended.

20일 전 | 0

| 수락됨

답변 있음
How to "free" or "destroy" pointer array of mxArray?
You must do each one. So mxDestroyArray(tmp[0]); mxDestroyArray(tmp[1]); mxDestroyArray(tmp[2]); or you could put these i...

20일 전 | 0

| 수락됨

답변 있음
Adjusting size of matrix when converting base 10 to binary
Specify the number of binary digits to use. E.g., dec2bin(30,8)

20일 전 | 1

| 수락됨

답변 있음
Index exceeds the number of array elements (2).
This line has y(3) dydt(2) = (2*k*uG-4*c*y(2)-2*c(y(2)-y(4))-2*k*y(1)-k*(y(1)-y(3)))/(2*m); What is the differential equation ...

20일 전 | 0

답변 있음
Split array into equal parts
You could reshape it and then access by columns. E.g., R = reshape(A,8,[]); Then A(:,1) is the first 8 values, A(:,2) is the s...

20일 전 | 0

답변 있음
Problems with Fortran MEX files with R2020b on Linux
So, the timestwo.F file that ships with MATLAB has bugs. I pointed this out to TMW several years ago, but I just checked and as...

20일 전 | 1

답변 있음
How to make two mxArray* scalar multiply each other?
x and y are pointers, so you need to dereference them to get at the double values they point to. So your code should be: plhs[...

21일 전 | 0

| 수락됨

답변 있음
Extracting data form a single cell
Draw{1}(1) is the rank and Draw{1}(2) is the suit.

21일 전 | 0

| 수락됨

답변 있음
Calculating the Most Similar Pair of Vectors using Cosine distance in a matrix
Use a standard matrix multiply to get the dot products. MATLAB is very fast at standard matrix multiplies. And then normalize ...

21일 전 | 1

답변 있음
How do I display my output for symbolic variables after solving them?
Convert to double first. E.g., Voltage2 = ["v2 = ",num2str(double(V2Sol))];

21일 전 | 1

| 수락됨

답변 있음
How to Loop in mexfunction?
You have a fundamental misunderstanding of how the C language works with pass-by-value scalar arguments. In this code: voi...

22일 전 | 1

| 수락됨

답변 있음
Mexfunction: Undefined function or variable
Your m-code can't see C functions inside your mex routine. You need to call the mex routine by its filename, and then inside th...

23일 전 | 0

| 수락됨

답변 있음
Multiplication chart In MATLAB
You don't need R. Just multiply ii*jj. E.g., fprintf('%g ', ii*jj) There are also ways to generate this table without any fo...

23일 전 | 0

답변 있음
Is it possible to pass functions as arguments to C++ MEX functions?
Just quickly skimming the MATLAB C++ API doc, it looks like you can do this using the matlab::engine::MATLABEngine::feval interf...

23일 전 | 0

| 수락됨

답변 있음
Program that sums as many numbers as user wants
An outline of the code could be: total = 0; while( true ) % insert code here to get a number from the user % insert ...

24일 전 | 0

| 수락됨

답변 있음
issue using indices...maybe?
You are doing a numeric itegration to generate the plotting points. Numeric integration will build up errors over time, so the ...

24일 전 | 0

| 수락됨

답변 있음
Finding the intersect between 2 lines
If you want the intersection of two lines and you have the equations of the lines, just use backslash. E.g., if you have these ...

24일 전 | 0

| 수락됨

답변 있음
Create a concatenated matrix in matlab
Change this HMC_Kh = [HMC_Kh; H]; to this HMC_Kh(i,1:numel(H)) = H; There were two problems with your current code. The numb...

24일 전 | 1

답변 있음
Sign of imaginary value changes after converting to array
Here is what I get: >> a = 2 + 1j; >> b = 1 + 3j; >> z1 = a*b z1 = -1.0000 + 7.0000i >> z2 = b*conj(b) z2 = 10 >>...

24일 전 | 1

답변 있음
How can I plot the function y = e^(-2x^2) * cos(4pi*x - 1.5)?
Pick a range for x. E.g., x = 0:0.01:2; y = exp(-2.*x.^2) .* cos(4.*pi.*x - 1.5); plot(x,y)

25일 전 | 0

| 수락됨

답변 있음
Where in my code using runge- kutta four step method did I make a mistake?
Type the following at the command line: edit rk4singlestep.m Then copy your code into that file and save it.

25일 전 | 0

| 수락됨

답변 있음
Projectile motion without drag
You don't define the Vx(k) value before using it, hence the error. Since your Vx values don't change you can fix this error by ...

26일 전 | 1

| 수락됨

답변 있음
Define x,y,z and evaluate them.
You can define variables simply by typical assignment. E.g., x=5; y=4; etc. You can use * for multiply and ^ for exponentiat...

26일 전 | 0

답변 있음
Fortran MEX returns only some elements of output array.
The problem isn't using allocatable variables ... MATLAB mex functions can handle that just fine. The problem is that you are u...

26일 전 | 1

| 수락됨

답변 있음
System of ODEs with interdependent variables
I would advise writing a derivative function for this. E.g., dydt = myderivative(t,y,gna,gk,gl,Vna,Vk,Vl,I) V = y(1); n = y(...

27일 전 | 0

| 수락됨

답변 있음
Outlet Limit: water depth and flow rate
You are being asked to write a function that takes H and Q as inputs, and outputs the diameter D. So the function outline would...

27일 전 | 0

답변 있음
writing out a quadratic
Use the element-wise operators that include the "dot" (such as .^ instead of just ^), and use the multiply operator * between th...

27일 전 | 0

답변 있음
How can I select three random sample of a matrix with minimum separation between samples?
A rejection method is straightforward. Simply make your selections in a forever loop until you get something that works. The a...

27일 전 | 1

| 수락됨

답변 있음
Cell to matrix under new variable
Do not do this! You are taking a method of storing your data that is easy to maintain and access (e.g., in a loop) and proposin...

27일 전 | 0

Load more