Réponse apportée
Column-wise inexing of matrix
One way that is scalable and matches your example: A(indx + (0:size(indx,2)-1)*size(A,1)) This uses implicit expansion. On ear...

plus de 7 ans il y a | 1

| A accepté

Réponse apportée
Multiply each column of a matrix by another matrix
Another way: C = sqrt(sum(E.*(J*E))); For the sizes involved, you probably won't see any significant timing differences betwee...

plus de 7 ans il y a | 1

| A accepté

Réponse apportée
What does zeros(2,3,4) mean?
It creates a double array of dimensions 2 x 3 x 4 filled with 0's. doc zeros

plus de 7 ans il y a | 1

Réponse apportée
Can ODE solvers produce different results when the MATLAB versions vary?
Running on 2006 version may be the only way to be sure. In general, it is not unusual to see differences in some function behav...

plus de 7 ans il y a | 0

Réponse apportée
How to convert an array of bytes to IEEE 754 single-precision float?
Try this: >> swapbytes(typecast(uint8([65 227 216 168]),'single')) ans = single 28.4808

plus de 7 ans il y a | 0

| A accepté

Réponse apportée
index an array with arrays
I'm still not exactly sure what you are trying to do, but If data is 1D and you want to set all values between the indexes to so...

plus de 7 ans il y a | 0

| A accepté

Réponse apportée
my code does not loop
You need to move your err initialization inside your loop. I.e., these lines need to move: iter=0; err=1; Also, you need to i...

plus de 7 ans il y a | 0

| A accepté

Réponse apportée
Segmentation violation while running mex file
The first thing I noticed is the code is not robust against an input that is not exactly as expected. E.g., You don't check tha...

plus de 7 ans il y a | 1

Réponse apportée
how to read binary file generated by Fortran
Unformatted Fortran is not the same as stream binary. Whereas stream binary is just the data itself, unformatted Fortran has ex...

plus de 7 ans il y a | 0

Réponse apportée
Array indices must be positive integers or logical values.
At least two problems. First, you need to start your for loop indexing at 1 instead of 0: for i = 1: n-1 % ending at n-1 so tha...

plus de 7 ans il y a | 0

Réponse apportée
Element multiplication and subtraction
If you are unsure, then just put dots next to every * and / and ^ operation. If a scalar happens to be involved it will still wo...

plus de 7 ans il y a | 0

Réponse apportée
Use Euler's method for Mass-Spring System
I will get you started. Let y be a 2-element vector containing your states. Define y as follows y(1) is defined to be x ...

plus de 7 ans il y a | 1

Réponse apportée
Can looping values be used for indexing?
finalpop, and thus LLPmatrix, has a 0 value as one of its elements. You then use this as an index within the loop, which is caus...

plus de 7 ans il y a | 1

| A accepté

Réponse apportée
how can i find the roots
You could wrap it in a loop. E.g., for I= 0:50 r = roots([0.013 -1*(0.013+I) I]); % do something with r here end

plus de 7 ans il y a | 0

Réponse apportée
How to modify a variable inside of a loop and use it outside the loop
What does this show: sum(times(:)>=800 & times(:)<900)

plus de 7 ans il y a | 0

Réponse apportée
what does this code represents? and why rand() has no value between parentheses?
rand() is the same as rand without the parentheses ... they both simply call the rand function with no input arguments. The beh...

plus de 7 ans il y a | 0

Réponse apportée
Solve 10 system of ODEs with separate functions and time dependent factors
This isn't going to work. You can't use random values in the derivative function for ode45. The derivative calls that ode45 mak...

plus de 7 ans il y a | 1

| A accepté

Réponse apportée
Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
What is size(dist) and size(v_e)? If these are row vectors, then maybe you need to do e*e' instead to get a scalar result.

plus de 7 ans il y a | 0

Réponse apportée
Loop through specific strcuture field names
As Stephen says, this is going to be slow. But maybe this syntax using dynamic field names would be useful to you: R{i}.([name...

plus de 7 ans il y a | 0

| A accepté

Réponse apportée
Create new cell array based on entries of other cell arrays
Not sure if this will suffice for your needs, but a simple way to get the unique strings in alphabetical order: arr4 = unique([...

plus de 7 ans il y a | 0

| A accepté

Réponse apportée
Normalizing a complex number
It is not clear what you are trying to do. You use the word "normalize" but it looks like maybe you are just trying to find the ...

plus de 7 ans il y a | 0

Réponse apportée
Which is more efficient: iteratively filling in a sparse matrix vs. creating a new sparse matrix every time i need to update the matrix?
Iteratively changing a sparse matrix causes the entire data set to be copied each time, so this is inherently not efficient and ...

plus de 7 ans il y a | 0

Réponse apportée
I have a matrix eg [1,6,3], and i have a 31*1 cell array ,each element of cell is a matrix. My problem is i wants to extract matrix from the cell position {1*1},{6*1},{3*1} and to be stored all these in separate matrices.
E.g., is this what you want? c = your 31x1 cell array v = your vector of indexes, e.g. [1,6,3] result = c(v); % extract the c...

plus de 7 ans il y a | 0

| A accepté

Réponse apportée
Error was detected while a MEX-file was running and MATLAB is exiting because of fatal error
Can you explain what you intended with these lines for A: double **A; : A = (double**)mxGetPr(prhs[0]); If y...

plus de 7 ans il y a | 0

| A accepté

Réponse apportée
inconsistency when comparing cell arrays with strings vs char array
This is a really good question. E.g., >> version ans = '9.4.0.813654 (R2018a)' >> strcmp("abcd","abcd") ans = logica...

plus de 7 ans il y a | 0

Réponse apportée
Voltage Measurement block: "do not delete this again". What is the story behind this?
Do not delete this "gain" ... not "again" P.S. Mathworks employees do have a sense of humor ... just not for this particular ca...

plus de 7 ans il y a | 1

| A accepté

Réponse apportée
Array Indexing Logical Values
"We know that rounding the index prevents the error" So that's a big clue. "Is there a hidden decimal place not being shown to...

plus de 7 ans il y a | 0

Réponse apportée
Matlab crashes when i create output matrix in mex.
I haven't had much time to look at this in detail, but at first glance this stands out: void createTable(unsigned int *dataStre...

plus de 7 ans il y a | 0

Réponse apportée
hi everybody , i have a question please , if i have X=[1:10] and Y=[-5:5] and i want to have all the point of the plane (x,y) , what can i do in matlab to extract this point to use it
Does this do what you want? [x,y] = meshgrid(X,Y); result = [x(:),y(:)]; Then iterate over the rows of result. Or you can ju...

plus de 7 ans il y a | 0

| A accepté

Réponse apportée
summation of sinx using summation
You are missing the alternating signs of the terms. E.g., you could put in a factor of (-1)^something to get this effect. The ...

plus de 7 ans il y a | 0

Charger plus