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

más de 9 años hace | 0

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

más de 9 años hace | 0

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

más de 9 años hace | 0

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

más de 9 años hace | 0

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

más de 9 años hace | 1

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

más de 9 años hace | 2

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

más de 9 años hace | 0

| aceptada

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

más de 9 años hace | 0

| aceptada

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

más de 9 años hace | 0

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

más de 9 años hace | 1

| aceptada

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

más de 9 años hace | 0

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

más de 9 años hace | 0

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

más de 9 años hace | 3

| aceptada

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

más de 9 años hace | 2

| aceptada

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

más de 9 años hace | 0

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

más de 9 años hace | 0

| aceptada

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

más de 9 años hace | 1

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

más de 9 años hace | 1

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

más de 9 años hace | 0

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

más de 9 años hace | 0

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

más de 9 años hace | 0

Respondida
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

más de 9 años hace | 2

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

más de 9 años hace | 2

| aceptada

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

más de 9 años hace | 2

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

más de 9 años hace | 0

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

más de 9 años hace | 0

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

más de 9 años hace | 0

Respondida
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

más de 9 años hace | 1

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

más de 9 años hace | 0

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

más de 9 años hace | 0

Cargar más