Answered
Write a MATLAB program that determines cos (x) using the Taylor series expansion.
Sn-1 is not meant to be typed in literally as you have done. It is meant to be the previous value of Sn. Also, x is required to ...

11 years ago | 2

| accepted

Answered
How to find the number of times an elements occurs in an array and copy to another array with same index
If you have a later version of MATLAB: >> A = [1 4 6 1 5] A = 1 4 6 1 5 >> B = histcounts(A,m...

11 years ago | 1

| accepted

Answered
Error operands of = have illegal types `pointer to double' and `double' in mex
You have created plhs[0] and plhs[1] as cell arrays, meaning that their data areas contain (mxArray *) types, not (double) types...

11 years ago | 0

Answered
How can I create a matrix of alternating 1s and 0s for any size matrix?
1 - mod(bsxfun(@plus,(1:n)',1:n),2)

11 years ago | 1

Answered
Running average from vector of data
x = 1:numel(AA); B = cumsum(AA)./x; plot(x,B);

11 years ago | 1

| accepted

Answered
how to solve the error
This line defined Icrop as a double: Icrop=zeros(1,1000000) And the curly braces { } in this line use lcrop as a cell ar...

11 years ago | 1

| accepted

Answered
matrix operation by element of other matrix
for i = 1:nmc a_trial = a + da(i); x = abs(a_trial) < abs(a); % Find all indexes where a_trial is closer t...

11 years ago | 0

Answered
Clearing variables in function workspace effect on memory
Once a function returns, all "local" variables to that function are automatically cleared. You don't need to manually do it. See...

11 years ago | 2

| accepted

Answered
How to extract length along an angle that intercepts an ellipse.
To get started, e.g., >> % Original data >> E = [1 0; 0 0.5] E = 1.0000 0 0 0.5000 >...

11 years ago | 0

Answered
What is the difference in these errors?
E.g., one way to get these errors: >> A = rand(3) A = 0.9649 0.9572 0.1419 0.1576 0.4854 0.421...

11 years ago | 1

| accepted

Answered
(AB)^T = (B^T*A^T) proof help
Transposing in MATLAB is accomplished with the ' and .' operators. The ' operator is actually conjugate transpose and the .' is ...

11 years ago | 0

| accepted

Answered
assigning array to another
Is this what you want? B = zeros(10,30); % initialize Matrix B as 10 X 30, first as zeros B(1:9,:) = A(1:9,:); % B take...

11 years ago | 1

| accepted

Answered
for loop output into matrix for pairwise comparisons
As you are starting to see, having variables with "dynamic" names ending in 1, 2, 3, etc. can quickly cause programming headache...

11 years ago | 2

Answered
Need help creating an array
And another way: A = full(spdiags(repmat([2 -4 2],n,1),[-1 0 1],n,n)); And yet another way: A = -4*eye(n); A(2:n...

11 years ago | 0

Answered
run C++ program in using MATLAB
Look at system and bang. E.g., http://www.mathworks.com/help/matlab/ref/system.html?searchHighlight=system http://www.math...

11 years ago | 1

Answered
dlmwrite function Could not open file
result.txt will go into your current directory. I.e., it will go into what this command shows: cd Do you have write perm...

11 years ago | 1

Answered
I'm not sure how to start out this program.
Read the doc for xlswrite here: http://www.mathworks.com/help/matlab/ref/xlswrite.html?searchHighlight=xlswrite Then look ...

11 years ago | 1

Answered
one thing i need to know
R = M' Or if you want to strictly transpose for complex arguments as well, R = M.'

11 years ago | 2

Answered
I am trying to create two vectors out of one,x, where one will contain all the positive elements and the other all the negative elements.
You are using k as a loop variable but only doing one iteration, k = 12. Maybe you want this result: P = x(x>0); N = x(x...

11 years ago | 0

Answered
Referring to variables with concatenated strings
Yes it is possible to do this using eval, but please do not do this! There are much better ways to organize your data using cell...

11 years ago | 1

| accepted

Answered
Making IF conditional sentance.
f is a vector, so the expression f<f1 is also a vector. And when you try to use this vector with the && operator you get the err...

11 years ago | 0

Answered
Undefined function 'm' for input arguments of type 'double
Error seems straight forward to me ... once you reach that line m is not defined, hence the error. Is m supposed to be a vector ...

11 years ago | 1

Answered
Why do I get: "Error using vertcat Dimensions of matrices being concatenated are not consistent."
Entire has e columns single has 1 column So unless e == 1, they won't match and hence the error. That being said, it looks...

11 years ago | 1

Answered
Approximating Euler's number using randomly generated integers
Consider this: Since you have K numbers from 1 to K, for every duplicate number that means another number in the sequence was no...

11 years ago | 1

| accepted

Answered
how to read data from a .mat file
Use the load function to read .mat files. E.g., load Ey1a.mat

11 years ago | 1

Answered
possible Bug? or checking if OverFlow happened?
How large is the average value? Is 100 close to eps of this average value? E.g., is the average value near 1e17? If so, this cou...

11 years ago | 0

Answered
Is it possible to add/combine matrices without increasing memory usage?
MATLAB can sometimes be coaxed into performing operations in place, but there are rules you must follow. Generally, you must be ...

11 years ago | 0

| accepted

Answered
Extract matrices of a particular size
C = your cell array DesiredSize = whatever; % e.g. [1 16] Z = cellfun(@size,C,'UniformOutput',false); % get matrix sizes ...

11 years ago | 0

Answered
How do I create random Boolean array with at least one 1 in each row?
For a row, e.g., n = number of random numbers in a row row = randi(2,1,n)-1; while( ~any(row) ) row = randi(2,...

11 years ago | 0

Answered
How do I use a 2D logical index matrix to change a subset of a 3D array?
data(cond(:)) = nan; % Use linear indexing since target is 1st plane

11 years ago | 0

Load more