Respondida
While loop will not stop running?
You are corrupting the value of k and not doing the term summing properly. These lines: k=1/(k+1)^2; term=sum1+(1/(k...

más de 9 años hace | 0

| aceptada

Respondida
Why this error is showing?
You can get allcomb, written by Jos, from the FEX here: http://www.mathworks.com/matlabcentral/fileexchange/10064-allcomb-var...

más de 9 años hace | 1

| aceptada

Respondida
For Loop for storing data
No loop needed: a = your very large matrix b = a(:,1:6:end); % every 6th column, starting with 1st column

casi 10 años hace | 0

Respondida
How to insert a matrix into a matrix
a = your 2x2 marix b = your 4x4 matrix b(3:4,1:2) = a;

casi 10 años hace | 2

Respondida
Problem in if-else if-else structure
You can't compare to NaN with the == operator, since NaN is not equal to anything (including itself). You must use the isnan fun...

casi 10 años hace | 1

Respondida
sparse function cannot get integer arrays for the indices
The sparse matrix storage has always been the following internally as far as I know (I think back to R2006a is all I have checke...

casi 10 años hace | 2

Respondida
how to save the dir output?
dir_list = dir('/D/myfolder');

casi 10 años hace | 0

Respondida
Finding roots of a polynomial
An n'th order polynomial will have n roots, some of which may be repeated or complex. You have a 3rd order polynomial which will...

casi 10 años hace | 0

| aceptada

Respondida
In an assignment A(:) = B, the number of elements in A and B must be the same.
Index your t variable inside the loop. E.g., dydt=-0.5.*exp(0.5.*t(i)).*sin(5.*t(i))+5.*exp(0.5.*t(i)).*cos(5.*t(i))+yi; ...

casi 10 años hace | 0

Respondida
Estimating pi using while loop for specific tolerence.
For starters, if you are taking the tolerance out to 12 digits and beyond, you need to use a more accurate value of pi for your ...

casi 10 años hace | 0

| aceptada

Respondida
Creating two random matrices
E.g., % random matrix M = rand(4,8); % normalize per the 4-element sums M(:,1:4) = bsxfun(@rdivide,M(:,1:4),sum(M(...

casi 10 años hace | 1

| aceptada

Respondida
how do I square a column in a matrix?
X = your 7x3 matrix X(:,3) = X(:,3).^2; % replace 3rd column with its square (element-wise) Note the dot in front of th...

casi 10 años hace | 0

| aceptada

Respondida
How to use command function?
I would advise using a cell array for this instead of many separately named variables. E.g., predictor = cell(15,1); for...

casi 10 años hace | 0

| aceptada

Respondida
Newbie needing to create matrix elements dependent on other elements
A = your Nx6 matrix A(:,7) = sqrt(sum(A(:,1:3).*A(:,1:3),2)); % The RSS of the 1st 3 columns by row

casi 10 años hace | 0

| aceptada

Respondida
I have a cell (NewCell {1,1}) with 1 column and many rows, each row has or '0' or []. If its '0', I want to make a comparison; if its the other thing, i want a 'V'.
elseif isempty(NewCell{1,1}{k}) The problem you are having is that the result of NewCell{1,1}{k} ~= '0' is empty in that br...

casi 10 años hace | 0

Respondida
Incorrect matrix substitution with ML2016b
You don't show your code, but my guess is you did one of the element-wise operations that now has scalar expansion built in. E.g...

casi 10 años hace | 0

| aceptada

Respondida
Why can't i plot this equation?
Use element-wise divide operator ./ instead of matrix divide operator / f=@(x)((1+x.^2-1.5*x.^3+0.5*x.^4)./(1+x.^4))

casi 10 años hace | 0

| aceptada

Respondida
Could someone please explain what is wrong in this simple code
Is this what you want? cm = @(x,Dt) exp((-x.^2)/(4*Dt))/2*(pi*Dt)^(1/2); Dt = [1/16,1/4,1]; x = -5:.01:5; for k=1:...

casi 10 años hace | 1

| aceptada

Respondida
Matrix dimensions must agree error
Looks like you want to do a string compare in these lines: if strcmp(raw{k,1},'Time, s') : if strc...

casi 10 años hace | 0

| aceptada

Respondida
How can I turn a data vector into a matrix of rows with the same vector?
If you just need to do the subraction: result = bsxfun(@minus,A,b); If you need your B for some other reason also, then:...

casi 10 años hace | 0

| aceptada

Respondida
Mean for 4D
umean = squeeze(mean(u,2));

casi 10 años hace | 0

| aceptada

Respondida
Variable B in a table (type = double) needs to calculated based on Variable A in the same table (type = double), but the key is that Variable B is calculated based on the value of Variable A in both the current row and the previous row. How please ?
When n=1 you are using an index of 0 which will cause an error. What do you want to do for the 1st element since there is no 0't...

casi 10 años hace | 0

Respondida
exceeds matrix dimensions error. How to solve
Enter this at the command line dbstop if error Then run your code. When the error is encountered, the program will pause...

casi 10 años hace | 0

Respondida
x = 10*((length00/2)-floor(length00/2)); what does this mean?
Did you try it to see what it does? E.g., >> length00 = 12.34 length00 = 12.3400 >> length00/2 ans = ...

casi 10 años hace | 1

Respondida
modifying the value of angle of a complex number?
z = your complex number a+bi e = your new angle znew = abs(z).*exp(1i*e);

casi 10 años hace | 1

| aceptada

Respondida
Computationally efficient Matrix-Vector multiplication
I am not following your suggestion. The link in question refers to an element-wise multiplication, which results in N^2 unique i...

casi 10 años hace | 0

Respondida
mexGetPr error when freeing the data
These lines show that rlist and r come from the MATLAB Memory Manager: rlist=mxGetPr(prhs[8]); r=mxGetPr(prhs[9]);...

casi 10 años hace | 0

| aceptada

Respondida
2d matrix to 3d matrix conversion with signals
x = your 900000x250 matrix xnew = reshape(x',250,150000,6);

casi 10 años hace | 0

Respondida
Volume of a cylinder
Seems like you have this information: V1 = pi*(r1^2)*h1 <-- this is all known V2 = 1.2 * V1 <-- this is given ...

casi 10 años hace | 1

| aceptada

Respondida
Extract elements from a heap
I am assuming you have a typo in your code above and are really starting with keys in sorted _"consistent"_ order ... i.e., I as...

casi 10 años hace | 1

| aceptada

Cargar más