Answered
Mex fortran code on Matlab R2013a, Linux 64: Illegal preprocessor directive
The warning indicates that something went wrong with the pre-processor. The error indicates that mwPointer is not defined. Wha...

9 years ago | 1

Answered
A Matrix full of Arrays
Use cell arrays. E.g., myMatrix = {1:2,1:3,1:4}; % <-- 3-element cell array of row vectors, each a different length myV...

9 years ago | 0

| accepted

Answered
how to remove specific rows of columns
Save the indexing that you use to do the removing, and then apply that to the original matrix during the reconstruction. E.g., ...

9 years ago | 0

| accepted

Answered
Problem with mean function
What does this show: sum(condition) If sum(condition) is 0, then you will get a NaN result in the mean calculation. E.g....

9 years ago | 0

Answered
Writing a taylor series function for e^x
You are missing the first term in the series (i.e., the 1). You could rectify this by modifying the sum line. E.g., ts = 1 ...

9 years ago | 0

Answered
Compare and remove entries from matrix
Do *NOT* delete items from a matrix in a loop! Every time you do so, it causes an entire data copy to take place. If you do th...

10 years ago | 0

Answered
Find and delete a double value in matrix
Use randperm, not randi. The randperm function will ensure that you do not get duplicate indexes to delete, whereas using randi...

10 years ago | 0

Answered
How to fix "cell contents assignment to a non-cell array object" error?
Not sure what you are trying to do here. tr is a cell array: tr={1,2,3,4,5,6} So accessing the contents of tr would eit...

10 years ago | 0

Answered
fopen gives error msg for a binary file
Are there any funny non-displaying characters in the file names? E.g., what does this show: d = dir; d = [d.name]; a...

10 years ago | 1

Answered
Need to round off 0s from a number to use the find command
Testing for equality after floating point operations is often problematic. Instead, e.g., using the min and abs functions: ...

10 years ago | 2

Answered
How to fix 'Undefined function or variable 'temp' in ode45'.
Where is the file temp.m located? Is it in the current directory or on the MATLAB path? Is it a sub-function? The error indic...

10 years ago | 0

| accepted

Answered
How to obtain array output from nested loops in user defined function
Slight changes to your code: function [ y ] = mae_exp(x, E ) %x is the power you want to take 'e' to, E is the error you...

10 years ago | 0

| accepted

Answered
want to print a matrix with in bits form
If you are just trying to manually print the matrix in that format, e.g., for k=1:size(S0,1) fprintf(' %02d',S0(k...

10 years ago | 0

Answered
help with structuring variables
Like this? continous_emissions = struct('final_m_co2_g_sec',final_m_co2_g_sec,... 'final_m_...

10 years ago | 1

| accepted

Answered
Want to simulate a sequence of results from rolling a nonhomogeneous die
The expression _rand(0,1)_ will produce a 0x1 sized matrix ... i.e., an empty matrix. That is not what you want. I will give yo...

10 years ago | 0

Answered
Pairewise difference with bsxfun function and run all variables into it
How were these A1, A2, etc variables created in the first place? This is bad programming practice and leads to obfuscated code....

10 years ago | 0

Answered
How can I test if an input value is an integer?
E.g., >> isaninteger = @(x)isfinite(x) & x==floor(x) isaninteger = @(x)isfinite(x) & x==floor(x) >> isaninteg...

10 years ago | 3

| accepted

Answered
Unable to clear mex file
I hadn't seen that TMW post about memory leaks and clearing mex routines. Not sure what the issue is there and what the other "...

10 years ago | 2

| accepted

Answered
If i want to know what algorithm or code is used in the back-end of any MATLAB in-built function....How can i know it? Is there any way or files ?
Some functions are just m-files that you can edit to get a look at them (e.g., polyval.m). Others are compiled executable code ...

10 years ago | 0

Answered
Force get 3*4 matrix
x = the user input if( ~isequal(size(x),[3 4]) ) error('Size must be exactly 3x4') end

10 years ago | 0

| accepted

Answered
How to input y' = 2x^3 - 2xy into matlab?
Maybe this? (2*x.^3)-(2*x.*y) But hard to say if this is correct for you application since we don't know the sizes of x ...

10 years ago | 1

Answered
Is the C API thread-safe?
In general, mex API functions are *not* thread safe. In particular, any functions that allocate/deallocate memory (e.g. the mxC...

10 years ago | 1

Answered
How can I replace a matrix of zeros with other values in one command?
Hint: If you assume F is not already existing, what happens if you just do the 2nd part? Try it. What happened? If you assu...

10 years ago | 0

Answered
how do i make this function accept vector values ?
Assuming you want to yield an error if *any* of the values yield complex roots, e.g., function [ Root] = Quadratic( a, b ,c...

10 years ago | 0

Answered
memory requirement for a complex sparse matrix
You can see this link: https://www.mathworks.com/matlabcentral/answers/126295-memory-usage-in-sparse-matrix Repeated for c...

10 years ago | 0

Answered
How to set up a conditional that will run if a particular vector has more than one column?
if( numel(W) == 1 ) % W is a scalar else % W is not a scalar end

10 years ago | 2

Answered
store values from a for loop in a column vector?
No need for the for-loop, just a one-liner: b = b0.*(x.^(m)./(K.^(m)+ x.^(m))); % <-- changed the / to a ./

10 years ago | 2

| accepted

Answered
Need Help with fixing "Error using vertcat Dimensions of matrices being concatenated are not consistent" for my matrix
Not sure what P1, P2, and P3 dimensions are, but maybe something like this is what you need: row0 = zeros(1,size(P1,2)); ...

10 years ago | 2

Answered
how to use an array with function to get another array
Well, you can certainly do the first part: a = lhsnorm(8,0.05,2000); F = @(x)0.5*x.^2 fa = F(a); For plotting, I a...

10 years ago | 0

Answered
Hello! Can somebody please tell me what's wrong with my code?
You need to break your double tests into two separate tests. E.g., elseif 90>marks>=80 should be elseif 90>marks &&...

10 years ago | 0

Load more