Answered
3d matrix multiplication with reduce computation time
Some testing issues I had: I couldn't run the posted code because npolinomi was not defined. Looking at the code, I made a g...

9 years ago | 0

| accepted

Answered
Is there anybody to help me fix the error and convert mxArray to double?
What happens if you add this prior to the "care" call: G0 = zeros(1,4);

9 years ago | 1

| accepted

Answered
Swapping the elements in a matrix
You've got hard-coded row numbers and matrix sizes in your code. Rather than doing that, along with all of the copy-pasting you...

9 years ago | 0

| accepted

Answered
How to delete a substring within a string
Assuming the cells to be deleted are all of the form {''}, you could simply use the isequal function. E.g. x = cellfun(@(y)...

9 years ago | 1

| accepted

Answered
How to shrink a pre-allocated array in a C-Mex?
I am unaware of specific documentation on this, but Part 1 should be sufficient (and safe) as long as you don't care about the w...

9 years ago | 1

| accepted

Answered
can anybody help me to solve my problem with mex instruction of "mld4bmf" library ?
You need to edit the matlabasso.c source file and replace the call to mxErrMsgTxt with mexErrMsgTxt.

9 years ago | 0

| accepted

Answered
C++ to 64-bit MEX
Start here: https://www.mathworks.com/help/matlab/call-mex-files-1.html

9 years ago | 0

Answered
How can i print the value of a variable in the text that is to be displayed while asking for an input?
E.g. x = input(sprintf('Enter the value of %dth variable ',i)) or x = input(['Enter the value of ' num2str(i) 'th ...

9 years ago | 0

| accepted

Answered
How to filter out multiple rows based on another array?
result = a(ismember(a,b));

9 years ago | 0

| accepted

Answered
Matlab provides different results for same formula
Is this just an index typo? You state 429,79 in your text, but the code has index 425,79. Also, the calculation in the loop ...

9 years ago | 3

| accepted

Answered
Expanding a Matrix with Repmat/Reshape?
E.g., z = cell2mat(cellfun(@(x,y)repmat(x,1,y),num2cell(x),num2cell(y),'Uni',false)); But this just hides the loops in t...

9 years ago | 0

| accepted

Answered
Read and access MAT file data in C
This: const int *dim_array; should probably be this const mwSize *dim_array; Also, this mxArray ***p; sh...

9 years ago | 1

| accepted

Answered
Error using mex (mxErrMsgTxt)
Source code typo. The function name is mexErrMsgTxt, not mxErrMsgTxt.

9 years ago | 3

| accepted

Answered
How to solve the varying length of strings of double pendulum in the simulation?
Do you have a profile of how the string lengths change as a function of time? E.g., can you do something like this: Have fun...

9 years ago | 0

Answered
Return Matrix to Original Order
Keep track of the original indexing. E.g., >> RPM_c = randperm(15) % sample data RPM_c = 10 9 15 6 ...

9 years ago | 3

| accepted

Answered
Manipulating strings defined with the new double quote option
extractBetween(s1,2,4)

9 years ago | 2

Submitted


LOADFIXNAMES loads a mat file, fixing invalid names
Loads a mat file into the caller's workspace, fixing invalid variable and field names.

9 years ago | 5 downloads |

5.0 / 5
Thumbnail

Answered
Non-repeating random integer generator with a seed
According to the doc for randperm, it uses the same random number generator as rand, randi, and randn. So you can control the s...

9 years ago | 0

| accepted

Answered
Finding matrix column index based on certain conditions
result = find(sum(A==1)==1 & sum(A==0)==(size(A,1)-1));

9 years ago | 0

| accepted

Answered
writing in other languages(C,python,...)
You can use the MATLAB editor to write C/C++ code. It is language sensitive. You cannot use C/C++ (or .h) files directly fro...

9 years ago | 2

Answered
how to change specific factor in a matrix
For the general case of changing numbers, you could do this: X = your array result_index = [4 1 6 5 3 2]; % 1 to 4, 2 ...

9 years ago | 0

| accepted

Answered
Cell contents reference from a non-cell array object, why?
As written, X0_r is a cell array, but the elements of this cell array are NULL (empty) since nothing has been put into it yet. S...

9 years ago | 0

Answered
A line of my code is T4=(T3.*T1)./T2 where T2 is a 1x10 double matrix and T3 is a 1x6double matrix. How can I reshape one of the matrices so that the line of code works enabling me to get values of T4. T1 is a 1x1 double.
E.g., to get all combinations of the elements: AT4 = bsxfun(@rdivide,AT3.*T1,T2A(:)); Or in R2016b or later AT4 = A...

9 years ago | 1

| accepted

Answered
Multiple inputs into for loop
E.g., to vary them at the same time numPixelSpinefromPhan = [2688.00 3619.00 4306.00 4009.00 5029.00 5224.00 4151.00 2518.0...

9 years ago | 0

| accepted

Answered
Multiply each column in MxN matrix with it's transpose to create MxMxN matrix
X = your MxN matrix [M,N] = size(X); Xcols = reshape(X,M,1,N); Xrows = reshape(X,1,M,N); result = bsxfun(@times,Xc...

9 years ago | 0

Answered
i am being asked to solve a problem by eulers method
See Euler's Method here: https://en.wikipedia.org/wiki/Euler_method Look at the examples. An outline to get you going on ...

9 years ago | 0

Answered
how can I increment 2 variables in a for loop at the same time?
There are several ways to achieve this. E.g., I = some range J = some range for k=1:numel(I) i = I(k); ...

9 years ago | 4

| accepted

Answered
Computing the pairwise distance matrix given a matrix of vectors
doc pdist e.g., result = squareform(pdist(vectorMatrix')); or drop the squareform if you are willing to do your own...

9 years ago | 1

| accepted

Answered
Using horzcat in a loop for combining large number of files
data_all= reshape(data,size(data,1),[]); Or, if you needed to vertcat them instead, then you could use result = reshap...

9 years ago | 0

| accepted

Answered
How to execute a function which has the same name as another variable?
The bottom line here is probably "don't do that" in your code. This is similar to using eval( ) or load( ) to pop variables int...

9 years ago | 0

Load more