Answered

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 =...

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 =...

4 mesi ago | 0

Answered

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{:});

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{:});

4 mesi ago | 0

Answered

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...

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...

4 mesi ago | 0

Answered

Using fprintf to save a matrix changes the order of my matrix

MATLAB stores 2D matrices in column order. That is, the numbers in your matrix are stored in memory in this order: 0, 1, 2, 3,...

Using fprintf to save a matrix changes the order of my matrix

MATLAB stores 2D matrices in column order. That is, the numbers in your matrix are stored in memory in this order: 0, 1, 2, 3,...

4 mesi ago | 0

Answered

please help me to convert c code into matlab code for partial shading of solar panel using equilibration algorithm

In addition to what @Image Analyst has written, I would advise turning this into a function with p1, p2, p3 as input arguments a...

please help me to convert c code into matlab code for partial shading of solar panel using equilibration algorithm

In addition to what @Image Analyst has written, I would advise turning this into a function with p1, p2, p3 as input arguments a...

4 mesi ago | 0

Answered

Difference between using single quotes ('xyz') and double quotes ("xyz") in formatspec

In MATLAB, single quotes ' ' are used to create char type variables, and double quotes " " are used to create string type variab...

Difference between using single quotes ('xyz') and double quotes ("xyz") in formatspec

In MATLAB, single quotes ' ' are used to create char type variables, and double quotes " " are used to create string type variab...

5 mesi ago | 0

| accepted

Answered

Error in ode45 while doing numerical integration

The function handle you pass to ode45( ) needs to have a (t,y) signature. E.g., [t,y] = ode45(@(t,y) myode(t,gt,g), tspan, ic, ...

Error in ode45 while doing numerical integration

The function handle you pass to ode45( ) needs to have a (t,y) signature. E.g., [t,y] = ode45(@(t,y) myode(t,gt,g), tspan, ic, ...

5 mesi ago | 0

Answered

How to multiply higher order matrices?

You may need to permute your arrays first to get your desired 2D slices in the first two dimensions. A = whatever B = whatever...

How to multiply higher order matrices?

You may need to permute your arrays first to get your desired 2D slices in the first two dimensions. A = whatever B = whatever...

5 mesi ago | 2

Answered

Using matrix to index another matrix?

Does this do what you want: x = sub2ind(size(B),(1:size(A,1))',A(:,1),A(:,2),A(:,3)); Output = B(x);

Using matrix to index another matrix?

Does this do what you want: x = sub2ind(size(B),(1:size(A,1))',A(:,1),A(:,2),A(:,3)); Output = B(x);

5 mesi ago | 0

| accepted

Answered

Equivalent of c++'s NULL or python' s None in MATLAB

This will probably depend on how these are used downstream in your code and whether you have arrays of them to deal with. If th...

Equivalent of c++'s NULL or python' s None in MATLAB

This will probably depend on how these are used downstream in your code and whether you have arrays of them to deal with. If th...

5 mesi ago | 1

Answered

X Y Z angles of a D20 (icosahedron) for gravity projection

If you have the 3D normal vectors, then all you need to do is take the dot product between them and the "flat" face normal vecto...

X Y Z angles of a D20 (icosahedron) for gravity projection

If you have the 3D normal vectors, then all you need to do is take the dot product between them and the "flat" face normal vecto...

5 mesi ago | 1

| accepted

Answered

modify a row of an array within a function

This can sometimes be done inplace depending on how you write the function and how you call the function. One requirement is yo...

modify a row of an array within a function

This can sometimes be done inplace depending on how you write the function and how you call the function. One requirement is yo...

5 mesi ago | 0

Answered

Operator '-' is not supported for operands of type 'function_handle'.

You are using u as both an input argument and a global function handle function A3 = odeFun(t, u) <-- input argument global R...

Operator '-' is not supported for operands of type 'function_handle'.

You are using u as both an input argument and a global function handle function A3 = odeFun(t, u) <-- input argument global R...

5 mesi ago | 0

Answered

Solve a system of 3 second order ODE

You will need to change your scalar equations to vector equations, and you will need to change your derivative function to a vec...

Solve a system of 3 second order ODE

You will need to change your scalar equations to vector equations, and you will need to change your derivative function to a vec...

5 mesi ago | 0

Answered

Need to speed up the generation of random numbers.

You could over generate a large matrix and then pick off the number of elements you need later. E.g., C = rand([5 size(A)]); T...

Need to speed up the generation of random numbers.

You could over generate a large matrix and then pick off the number of elements you need later. E.g., C = rand([5 size(A)]); T...

5 mesi ago | 0

Answered

How do i create a large matrix with a formula?

N = 1000; a = 2 * pi * f * T * (0:N-1)'; x = [cos(a) -sin(a)];

How do i create a large matrix with a formula?

N = 1000; a = 2 * pi * f * T * (0:N-1)'; x = [cos(a) -sin(a)];

5 mesi ago | 1

Answered

Matrix multiplication to get covariance matrix

@Tintin Milou MATLAB variables do not have a "symmetric" attribute flag that I know of. Just because you create a variable that...

Matrix multiplication to get covariance matrix

@Tintin Milou MATLAB variables do not have a "symmetric" attribute flag that I know of. Just because you create a variable that...

5 mesi ago | 0

Answered

Why can't complex integer arithmetic be done?

I think the main reason for disallowing integer array arithmetic in MATLAB is because of the ambiguity caused by the max(min( ))...

Why can't complex integer arithmetic be done?

I think the main reason for disallowing integer array arithmetic in MATLAB is because of the ambiguity caused by the max(min( ))...

5 mesi ago | 1

Answered

How can I split C/C++ Code in multiple files and still use MEX

Use the -c option to compile the B and C stuff to produce only object files without any linking: mex -c B.c C.c Then compile y...

How can I split C/C++ Code in multiple files and still use MEX

Use the -c option to compile the B and C stuff to produce only object files without any linking: mex -c B.c C.c Then compile y...

5 mesi ago | 1

| accepted

Answered

Matrix multiplication. Trying to get scalar solution

Those should be matrix multiples, not element-wise multiplies. Remove the dots. E.g., top=nMode * M * u0; bot=nMode * M * nM...

Matrix multiplication. Trying to get scalar solution

Those should be matrix multiples, not element-wise multiplies. Remove the dots. E.g., top=nMode * M * u0; bot=nMode * M * nM...

5 mesi ago | 0

| accepted

Answered

Adapt RK4 ODE Solver from first order to 2nd order

Try this for starters yt = zeros(numel(y0),length(h:tfinal)); %Memory Allocation And then maybe this is what is intended for i...

Adapt RK4 ODE Solver from first order to 2nd order

Try this for starters yt = zeros(numel(y0),length(h:tfinal)); %Memory Allocation And then maybe this is what is intended for i...

5 mesi ago | 0

| accepted

Answered

Error using vertcat Dimensions of arrays being concatenated are not consistent.

You have a mismatch in the number of arguments. E.g., this [V,y] = ode45(@(~,y) fun(del_h1,del_cp1,cp1),Vspan,y0); should be ...

Error using vertcat Dimensions of arrays being concatenated are not consistent.

You have a mismatch in the number of arguments. E.g., this [V,y] = ode45(@(~,y) fun(del_h1,del_cp1,cp1),Vspan,y0); should be ...

5 mesi ago | 0

Answered

Replacing matrix n column values

E.g., temp = A(:,70:80); temp(temp<0) = 0; A(:,70:80) = temp;

Replacing matrix n column values

E.g., temp = A(:,70:80); temp(temp<0) = 0; A(:,70:80) = temp;

5 mesi ago | 1

| accepted

Answered

Solving an overdetermined system of linear equations

Since you can simply plug in those values to verify that they satisfy all four equations, the conclusion would be that you have ...

Solving an overdetermined system of linear equations

Since you can simply plug in those values to verify that they satisfy all four equations, the conclusion would be that you have ...

5 mesi ago | 0

| accepted

Answered

How to create a cell array with binary numbers?

Your pop variable has 1000x11 = 11000 elements. Your for-loop only assigns values to 1000 of those elements (the first column)....

How to create a cell array with binary numbers?

Your pop variable has 1000x11 = 11000 elements. Your for-loop only assigns values to 1000 of those elements (the first column)....

5 mesi ago | 0

Answered

invalid use of operator

You are missing a ( after the second "if", and you are missing an "end" statement. That being said, my suggestion would be to u...

invalid use of operator

You are missing a ( after the second "if", and you are missing an "end" statement. That being said, my suggestion would be to u...

6 mesi ago | 0

Answered

Need Help Solving Two Coupled ODEs

The derivative function needs to have the input arguments specified. In your current code above, you have no inputs specified. ...

Need Help Solving Two Coupled ODEs

The derivative function needs to have the input arguments specified. In your current code above, you have no inputs specified. ...

6 mesi ago | 0

| accepted

Answered

Versions of Euler Methods

methodA has a fundamental flaw: y(i+1) = y(i)+ h*func( t(i) + h/2, (y(i)+y(i+1))/2 ); You can't use y(i+1) on the right hand s...

Versions of Euler Methods

methodA has a fundamental flaw: y(i+1) = y(i)+ h*func( t(i) + h/2, (y(i)+y(i+1))/2 ); You can't use y(i+1) on the right hand s...

6 mesi ago | 1

Answered

Problem with matrix differential equation resolve in Matlab with ode45

Normally I would have expected ode45( ) to pass q as a 4x1 column vector. Also, I don't see anything in your code solving for q...

Problem with matrix differential equation resolve in Matlab with ode45

Normally I would have expected ode45( ) to pass q as a 4x1 column vector. Also, I don't see anything in your code solving for q...

6 mesi ago | 0

| accepted