已回答
How to get the same number of char as number of decimals using num2str?
You might look into using the fix( ) function to isolate the fractional part of your number and then work with that directly.

2 years 前 | 0

已回答
matrix to struct do not match
You should really show us all of the actual code in question, not just a wordy description of the code. A better description and...

2 years 前 | 0

| 已接受

已回答
Assign elements in multidimensional struct to 2D array
You can use the vercat( ) function to force the comma-separated-list generated by C.pts to stack vertically: for ii=1:5, C(ii)....

2 years 前 | 1

| 已接受

已回答
Singular Value Decomposition calculation of a matrix
By changing the order of the rows you have changed the order of operations inside svd( ). The two answers are essentially the sa...

2 years 前 | 1

| 已接受

已回答
Issue with N body problem using ode45
You need to rethink your problem statement and initial conditions. The initial positions can't possibly be in the neighborhood o...

2 years 前 | 0

已回答
What is the best function of the following shape?
There are lots of functions that could fit this general shape. E.g., sin(x), or more generally A*sin(B*x+C) depending on width a...

2 years 前 | 1

已回答
Rotate an image 180 degrees without library functions
Hint: Take a small example, rotate it 180 degrees, and see where the elements end up. Then consider how you might get that resul...

2 years 前 | 0

已回答
How to rearrange columns in a MATRIX?
One way: [X(:,1:2);X(:,3:4)]

2 years 前 | 0

已回答
How to calculate the mean value of the non vero value in a vector?
Another way that doesn't require any data copying: M = [0.7,0.3,0]; sum(M)/nnz(M) Be aware that if there are no non-zero elem...

2 years 前 | 1

已回答
Adding value from structure into a vector after each iteration of a for loop.
The reason you are getting a 2x8x2 answer is because you start with a 1x8 vector but then assign spots outside of those limits i...

2 years 前 | 0

已回答
parallel sum different from serial sum
Bruno and IA have already given the reasons for this discrepancy. I would simply add that even though you are adding integers an...

2 years 前 | 2

已回答
how to multiply quaternion wth 1x3 vector
Use BECI as the "vector" part of a quaternion and put a 0 in the "scalar" part, and use that new quaternion in the multiply. Sin...

2 years 前 | 1

| 已接受

已回答
I want to convert vector into matrix with all possible combinations
I think John D'Errico answered this some time ago, or a question very much like this. But I can't find his post at the moment. I...

2 years 前 | 0

已回答
Can compare between vector and array
Does this do what you want? Finds the row numbers in A that match x. find(all(A==x,2))

2 years 前 | 0

| 已接受

已回答
Modify off diagonal elements of Matrix without looping
You could use logical indexing to get at the off-diagonal elements. E.g., A(~eye(size(A))) = skalar;

2 years 前 | 0

| 已接受

已回答
How to get two 16-bit numbers from a 32bit number
E.g., to split a uint32 into two uint16 you can use typecast( ): result = typecast(your_variable,'uint16') This result will co...

2 years 前 | 0

已回答
pass a vector from matlab to a c++ program
This really depends on what your C++ program does, but the simplest approach is to use a mex routine. You will need a supported ...

2 years 前 | 0

| 已接受

已回答
Write multiple variables from a function
Maybe something like this does what you want, with each qq1 and qq2 2D page results in the first two dimensions. [m n] = size(s...

2 years 前 | 0

已回答
In an assignment A(I) = B, the number of elements in B and I must be the same.
" And in the work space y2 is 3x1 and d is 1x1 " Then d - y2 will be 3x1. You can't assign a 3-element vector to a 1x1 scalar w...

2 years 前 | 0

已回答
After the if statement is ran why is the answer 10?
A=1; : if A<0 A is not negative, so the body of the if-test never runs.

2 years 前 | 0

已回答
Solve nonlinear 2nd order ODE numerically
You can look at the examples for ode45( ) here: https://www.mathworks.com/help/matlab/ref/ode45.html?searchHighlight=ode45&s_ti...

2 years 前 | 1

已回答
The input function does not work well
Pass in a vector using the square brackets. E.g., binary_to_decimal([1 0 0 1 1 0])

2 years 前 | 0

| 已接受

已回答
Concatenate logical/numerical arrays element wise
Here is one way: % Generate sample data H{1} = rand(2,3)<0.5; H{2} = rand(2,3)<0.5; H{3} = rand(2,3)<0.5; Hc = cat(3,H{:}) ...

2 years 前 | 2

| 已接受

已回答
What is the difference between " while 1" and "while true", Should I use one over the other?
1 is a double class scalar and true is a logical class scalar, so the check for "non-zero" is slightly different for each even t...

2 years 前 | 0

| 已接受

已回答
I have a 4 Dimensional Matrix and i want to get its transpose
Maybe this does what you want, which is transpose the first two dimensions: permute(val,[2 1 3 4]) Or you could use this funct...

2 years 前 | 0

已回答
How to multiply a 3d array with a 2d matrix?
It would be best if your 2D pages were the first two dimensions. That way the 2D pages are contiguous in memory and you can use ...

2 years 前 | 1

已回答
Error in concatination in binary values
c1=[8 14 10 9 6 3 2 7 6 11 6 3 13 15 6 0]; NewR = c1(1:2:end)*16 + c1(2:2:end)

2 years 前 | 0

已回答
Increased time for setting elements in sparse matrix
Every time you change the elements of a sparse matrix, MATLAB has to deep copy all the existing elements to a newly allocated ch...

2 years 前 | 1

已回答
How to run a Matlab file which uses functions from .c and .dll files?
It appears that this may be an older mex routine? Is there a "mexFunction" in the c file? If so, maybe you can just recompile it...

2 years 前 | 1

| 已接受

已回答
Unable to perform assignment because the left and right sides have a different number of elements.
Why are you replacing the sin(y-c) term with approximations? Why haven't you just programmed it as is? It appears you have done ...

2 years 前 | 0

加载更多