Respondida
The most efficient way to add a new column or new row to a sparse matrix
In general, every time you significantly change the size of a sparse matrix (so that you exceed the current nzmax of the matrix)...

alrededor de 9 años hace | 1

| aceptada

Respondida
why this code is not running ? the workspace remains empty.
Once flag gets set to 1, you don't ever reset it to 0 so you effectively disable the rest of your code and count ceases to incre...

alrededor de 9 años hace | 0

| aceptada

Respondida
How to transpose image and use permute instead?
Transpose the first two indexes: Eleven3 = permute(Eleven3,[2 1 3]);

alrededor de 9 años hace | 0

| aceptada

Respondida
Plotting suddenly not coming up
This is just a guess, but perhaps you are running a script which populates the current workspace with variables, and those varia...

alrededor de 9 años hace | 0

Respondida
Some problem about ceil()
Yeah ... floating point arithmetic bites again: >> num2strexact(215.08/0.152) ans = 1.4150000000000002273736754432320...

alrededor de 9 años hace | 1

| aceptada

Respondida
Reading binary file with fread and typecast
try val2 = swapbytes(typecast(uint8(val1),'int32'));

alrededor de 9 años hace | 0

| aceptada

Respondida
How to replace values in specific lines and on determined conditions
Something like this? v = m(10276:128597,10); v( v > 11 & v < 33 ) = 1; v( v > 34 & v < 56 ) = 5; : m(10276:...

alrededor de 9 años hace | 1

| aceptada

Respondida
How to reshape/transform matrices with 3D data?
[y,x] = ndgrid(Y,X); x = x(:); y = y(:); z = reshape(Z',[],1);

alrededor de 9 años hace | 0

| aceptada

Respondida
I am trying to use a script to run simpsons rule to numerically integrate a function, it keeps giving me an error.
A script is an m-file that has MATLAB statements in it only, *without* a function statement. E.g., File myfun1.m: x = ...

alrededor de 9 años hace | 0

Respondida
Solving for theta at different time steps
E.g., >> t = 0; >> f = @(theta) 47.9618*theta + 15.9809*sin(2*theta) - 20.780136*t; >> fzero(f,0) ans = 0 ...

alrededor de 9 años hace | 1

| aceptada

Respondida
Mex programming for a beginner
For the mex routine approach, assuming you can link with the library properly per Philip's comments, I have the following commen...

alrededor de 9 años hace | 1

| aceptada

Respondida
Generating position and velocities at different points on an ellipse
For the elliptical equivalent to uniform circular motion, I suppose you could have three choices. 1) Pick uniform angular mot...

alrededor de 9 años hace | 2

| aceptada

Respondida
What's the difference between the two pointer operators in the code gen?
I don't know _why_ the Coder will produce one form vs the other form, but by definition in the C language they mean exactly the ...

alrededor de 9 años hace | 0

| aceptada

Respondida
Writing mat file from C++ using API, empty matrix
Some problems: 1) data2 doesn't point to any of your double data ... it points to pointer_to_double values. So using memcpy ...

alrededor de 9 años hace | 0

| aceptada

Respondida
Matlab crashes when running MEX Files with large array dimensions
There are several issues: 1) You don't prototype your test function. The compiler encounters this line: test(inMatr...

alrededor de 9 años hace | 0

| aceptada

Respondida
Largest value near a 0
If I understand the assignment correctly, maybe you can use this as an outline: y = -inf; for i = 1:length(x) % W...

alrededor de 9 años hace | 2

| aceptada

Respondida
How to "squeeze" / transfer variables from a row vector into a NxN matrix?
Since MATLAB stores 2D matrix values in column order, a simple reshape will do the job: B = reshape(A,3,7); If you wante...

alrededor de 9 años hace | 1

| aceptada

Respondida
complex numbers multiplication in double precision
_"... Mind that the phases are of the order of magnitude of 10^10 radians. ..."_ When you have angles that large, I have to s...

alrededor de 9 años hace | 0

Respondida
How to project given vectors in matlab
E.g., see this link https://en.wikipedia.org/wiki/Vector_projection u = v2/norm(v2); result = dot(v1,u)*u;

alrededor de 9 años hace | 0

Respondida
Generate random permutation matrix
Another way: A = eye(n); A = A(randperm(n),:);

alrededor de 9 años hace | 4

Respondida
Vector must be same lengths - please help me
I am not exactly sure how you want things plotted, but maybe this? %plot(omega, x(:,2)); plot(t,x(:,2)); hold on; grid o...

alrededor de 9 años hace | 0

Respondida
How to Solve RESHAPE Function Error
Either: 1) The total number of elements of plmprofile1 is different between the reshape(plmprofile1,90,180) call and the resh...

alrededor de 9 años hace | 0

Respondida
How to extract column in particular interval from original matrix and to form new matrix?
L4 = L3(:,1:3:end);

alrededor de 9 años hace | 0

| aceptada

Respondida
Matrix calculation + loop
Maybe this is what you want: B0 = whatever V = whatever sigma_sum = V; M = eye(4); % <-- I am guessing that you r...

alrededor de 9 años hace | 0

Respondida
Is this a bug??
We really need to know the data types and values involved. E.g., with int8 >> a = int8([0 0]) a = 0 0 >> b ...

alrededor de 9 años hace | 1

Respondida
how can we find the intersection point of two polynomial equations?
Subtract them and then use the roots function on the result.

alrededor de 9 años hace | 1

Respondida
How to create a loop function within the same array?
A vectorized version (assuming I understand your dimensions correctly): diffI = [1;diff(ID(:,1))]; diffE = [0;diff(E(:,1...

alrededor de 9 años hace | 0

Respondida
Function of ODE can not be executed well.
Make sure the derivative function returns a column vector. E.g., function dy = myODE(~,y) dy = zeros(2,1); % <-- column...

alrededor de 9 años hace | 0

Respondida
Finding maximum value of a column in a matrix
[~,x] = max(A(:,1)); B = A(x,:);

alrededor de 9 años hace | 0

| aceptada

Respondida
Why does the following error come up for this short piece of code?
What is n? A vector? Maybe you need: H = hilb(n(i));

alrededor de 9 años hace | 0

| aceptada

Cargar más