Risposto
Properly resizing mxCreateStructMatrix post-2018a?
TMW doesn't publish the complete rules for how the data areas of structs are organized, but historically they have always put ea...

quasi 5 anni fa | 0

Risposto
How to get the ceofficients of a expression derived by ODE or integral ? For exampli,C1 and C2 in u
Typically these would be obtained by combining the solution with initial values for u. Do you have initial values?

circa 5 anni fa | 0

Risposto
Conversion Wolfram Mathematica to Matlab (Do loop)
result = sum(1:100);

circa 5 anni fa | 0

Risposto
Is it possible to vectorize this 'for loop' involving multiple matrix inversions
You might look at this FEX submission by Bruno Luong: https://www.mathworks.com/matlabcentral/fileexchange/24260-multiple-same-...

circa 5 anni fa | 0

| accettato

Risposto
Mulitplying 3D matrix by 3D matrix - result being 4D.
result = pagemtimes(matrix1,reshape(matrix2,3,512,1,512));

circa 5 anni fa | 0

| accettato

Risposto
Matrix dimensions must agree error problem
Use element-wise division with the dot: Y=acosd(sin(altitude)*sin(latitude)-sin(declination)./(cos(altitude)*cos(latitude))); ...

circa 5 anni fa | 0

Risposto
Combining two Matrices every other row
You could do direct assignment. E.g., [m,n] = size(A); C = zeros(2*m,n); C(1:2:end,:) = A; C(2:2:end,:) = B;

circa 5 anni fa | 1

Risposto
Gauss-Elimination method
See the rank( ) function: https://www.mathworks.com/help/matlab/ref/rank.html?s_tid=doc_ta

circa 5 anni fa | 1

Risposto
Looping num2str
x(i) references a single element of x. However, the expression [num2str(y(i)),'%'] generates multiple characters. In essence, ...

circa 5 anni fa | 1

Risposto
Mean computaion in matlab
You can specify the dimension to use with the mean( ) function. E.g., maybe this is the computation you want: data = your 3D m...

circa 5 anni fa | 0

Risposto
What is the mean?
B' is the complex conjugate transpose of B. If B is real, then it is equivalent to just the tranpose and the assignment simply ...

circa 5 anni fa | 0

| accettato

Risposto
How can I model equation of motion (2nd order ODE) when system matrices are in terms of state variables?
Yes you can have derivative functions that depend on state variables. This is quite common. E.g., define a 4x1 state vector y th...

circa 5 anni fa | 0

Risposto
empty double matrix in case of nul value
Do you mean you want to do something like this: if( isempty(malicious) ) malicious = 0; end

circa 5 anni fa | 0

Risposto
To allocate character array='2a'
'2a' is a two element character string. You can't assign two elements to a single element. I.e., you can't assign a 1x2 vector...

circa 5 anni fa | 0

Risposto
How to get the desired quaternion representation from a rotation matrix?
As you already know, both q and -q represent the same rotation. Which sign to pick is entirely up to the underlying algorithm. ...

oltre 5 anni fa | 0

| accettato

Risposto
Implementation of Runge Kutta Numerical Solution for system of ODE's
The main technical problem (other than your syntax not being MATLAB) is that you are trying to solve your four 1st order equatio...

oltre 5 anni fa | 0

| accettato

Risposto
How to convert complex float to complex integer in MEX gateway function?
I would guess you can just use the appropriate data types. E.g., mxComplexInt32* Data1 = mxGetComplexInt32s(prhs[0]); mxComp...

oltre 5 anni fa | 0

| accettato

Risposto
Can you help me with this loop?
Can you use num2str? Message = [num2str(TotalMinutes) ' minutes are equal to ' num2str(Hours) ' hours and ' num2str(Minutes) ' ...

oltre 5 anni fa | 0

Risposto
How to separate a string(1x1 cell) into a 1x4 cell
If the hex codes are always 8 characters, why can't you just pick off the characters you want? E.g., {result(1:8),result(10:17...

oltre 5 anni fa | 1

Risposto
how to generate a code for solving 2st order differential equations using improved runge kutta 4th order method
The posted code actually has a bug. Also it is almost set up properly for vector solutions, but not quite. Make these changes:...

oltre 5 anni fa | 0

Risposto
Computer crashed when calculating matrix (mixed with sparse and full) multiplication and summation
Remember that each element of the B*C result is simply the dot product of a row of B with a column of C. If that column of C ha...

oltre 5 anni fa | 0

| accettato

Risposto
Fast vector reshaping/permutation
Don't do the permute( ) operation. Just use pagemtimes( ) downstream in your code with the appropriate 'transpose' option. Thi...

oltre 5 anni fa | 1

Risposto
Can someone explain this Loop?
Of the numbers 1 ... 10 that get produced by the randperm( ) call, only three of them are less than 4: 1, 2, 3. 1 will cause n...

oltre 5 anni fa | 0

| accettato

Risposto
How to generate unique random integers between 1 to n (with no possibility of Sequence)
If 1:n is the only sequence you don't want, just use randperm(n) and reject the one case you don't want. I.e., if you get it the...

oltre 5 anni fa | 0

Risposto
How do solve four variables with one equation using Runge-kutta?
You have three state variables, namely v, lc, and z. But you only have code for updating v. You need code for updating lc and ...

oltre 5 anni fa | 2

| accettato

Risposto
A code and plot a graph for a projectile motion of a ball
Your main problem is that you don't have enough state variables. You have these two equations: x'' = 0 y'' = -g That's two 2...

oltre 5 anni fa | 0

Risposto
Converting Struct field to array
Does this do what you want? MyMatrix = vertcat(MyStruct.Field);

oltre 5 anni fa | 14

| accettato

Risposto
Trying to build a new nx4 array from an existing nx4 array using logical values
Assuming quatAB is a standard numeric matrix, use your logical variable for the first index and colon for the second index: m =...

oltre 5 anni fa | 0

Risposto
How do I combine a structure array into one structure
F = fieldnames(A); n = numel(F); C = arrayfun(@(i)vertcat(A.(F{i})),1:n,'uni',false); FC = [F';C]; B = struct(FC{:});

oltre 5 anni fa | 0

Risposto
Finding optimal value for x
You could try this function to get numeric values for local minimums: https://www.mathworks.com/help/matlab/ref/fminsearch.html...

oltre 5 anni fa | 0

Carica altro