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

9 years ago | 2

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

9 years ago | 1

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

9 years ago | 2

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

9 years ago | 0

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

9 years ago | 0

| accepted

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

9 years ago | 0

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

9 years ago | 0

| accepted

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

9 years ago | 1

| accepted

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

9 years ago | 0

| accepted

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

9 years ago | 0

| accepted

Answered
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

9 years ago | 0

| accepted

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

9 years ago | 0

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

9 years ago | 0

| accepted

Answered
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))

9 years ago | 0

| accepted

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

9 years ago | 1

| accepted

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

9 years ago | 0

| accepted

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

9 years ago | 0

| accepted

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

9 years ago | 0

| accepted

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

9 years ago | 0

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

9 years ago | 1

Answered
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);

9 years ago | 1

| accepted

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

9 years ago | 0

Answered
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]);...

9 years ago | 0

| accepted

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

9 years ago | 0

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

9 years ago | 1

| accepted

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

9 years ago | 1

| accepted

Answered
Matlab crashing when evaluating mex
Here is some sample code for you to peruse. It takes a 2D matrix input and writes the input values to the screen using various ...

9 years ago | 1

| accepted

Answered
Problem With Graph In Function
E.g., something like this to get you started T = 1:1:t+1; m = size(X,1); figure(1); G = plot(T',X'); legend([re...

9 years ago | 0

| accepted

Load more