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

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

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

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

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

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

9 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_...

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

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

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

9 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 "...

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

9 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

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

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

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

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

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

9 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

9 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 ./

9 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)); ...

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

9 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 &&...

9 years ago | 0

Answered
Why does my code say too many input arguments?
How are you calling this function? E.g., >> cubicxxxx(1:4) % <-- one input vector x0 = 1 >> cubicxxxx(2:5) ...

9 years ago | 0

Answered
How can i generate a vector of odd +ve numbers consisting of a defined number of elements
Just increase that top number. E.g., a = 1:2:2*n

9 years ago | 1

Answered
access multidimensional array per row
i2 ranges from 1 to 1st dimension of Results{i1}, which is 672. You can't then turn around and use this as the 2nd index in Res...

9 years ago | 0

Answered
Generate a list of array components interpreted as a comma separated list
If C can be passed in as a cell array, you could do this: fun = @(C) F(C{:}); The C{:} part will expand as a comma separ...

9 years ago | 0

Answered
Write a script.Create a vector of five random integers, each in the range from -10 to 10.Perform each of the following:•Subtract 3 from each element•Count how many are positive•Get the minimum
To create a script file, do the following at the command prompt: edit my_script_name.m The editor should open up a file ...

9 years ago | 0

Answered
How can I save only content of matlab figure ?
You might check out this FEX submission by Yair Altman: http://www.mathworks.com/matlabcentral/fileexchange/23629-export-fig ...

9 years ago | 0

Answered
Finding if a random walk "hits" a target in two dimensions
For 2D I assume you have x and y vectors that you are building at each step, and that Target is a 2-element vector with an x and...

9 years ago | 0

| accepted

Load more