Answered
How can I write this function handles in MatLab: f(x)= trace(CA^(x)VA^(x)') + sum_{i=1 to x}(trace(CA^(x-i)WA(x-1)')) - mu ?
For something like this, it would probably be best to just create an m-file to do the calculations, and then create a function h...

9 years ago | 0

Answered
How to remove rows from cell array based on multiple conditions?
E.g., assuming your columns are nice and are not mixed class: C = your cell array S = your cell string compare array, e....

9 years ago | 0

| accepted

Answered
How to convert matlab code to C code?
See this link about the MATLAB Coder: https://www.mathworks.com/help/coder/index.html

9 years ago | 0

| accepted

Answered
How to replace a row in one matrix with a particular row from a different matrix
Something like this maybe does what you want: A = your large matrix B = your smaller matrix [y,x] = ismember(B(:,1),A...

9 years ago | 1

| accepted

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

9 years ago | 1

| accepted

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

9 years ago | 0

| accepted

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

9 years ago | 0

| accepted

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

9 years ago | 0

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

9 years ago | 1

| accepted

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

9 years ago | 0

| accepted

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

9 years ago | 1

| accepted

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

9 years ago | 0

| accepted

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

9 years ago | 0

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

9 years ago | 1

| accepted

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

9 years ago | 1

| accepted

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

9 years ago | 2

| accepted

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

9 years ago | 0

| accepted

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

9 years ago | 0

| accepted

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

9 years ago | 0

| accepted

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

9 years ago | 2

| accepted

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

9 years ago | 1

| accepted

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

9 years ago | 0

Answered
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;

9 years ago | 0

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

9 years ago | 4

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

9 years ago | 0

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

9 years ago | 0

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

9 years ago | 0

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

9 years ago | 1

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

9 years ago | 1

Load more