Answered
multiply scalar with struct regarding
Well, just this: s.f = rand(3); % a matrix in a struct field x = rand; % a scalar result = x * s.f; % multiply a s...

9 years ago | 1

Answered
C consists of 258*1258 double with NaN in it.How can I replace all NaNs with blank entries and store as a same format 258*1258 doublet?
It is not clear what the entries of C actually are. Looks like a cell array from your {[]} syntax, but you mention an apparent ...

9 years ago | 0

| accepted

Answered
how to search through cell array of char vectors
Type the following at the command line: dbstop if error Then run your code. When the error occurs, the code will pause a...

9 years ago | 0

| accepted

Answered
Always getting 255 while adding.
All of the integer types clip resulting values at both ends. So for uint8 it clips the lower end at 0 and the upper end at 255. ...

9 years ago | 0

| accepted

Answered
Can anyone help to creat this vector ?
You're close, but you need to handle the W(i)=V(i) differently. The way you have it currently coded, this line is overwriting al...

9 years ago | 0

| accepted

Answered
Polynomial fit from the equation
You appear to have both x and time meaning the same thing, and y and data meaning the same thing. Maybe it is just a variable na...

9 years ago | 0

Answered
how to return column index in matrix
x = your original matrix [~,idx] = min(x,[],2);

9 years ago | 2

| accepted

Answered
what's the second variable in size function do ?
The second argument to the size function designates the particular dimension that you want. E.g., in your example, f is a 1x4. T...

9 years ago | 28

| accepted

Answered
Find maximum intermediate product in matrix multiplication
Another way using a loop, which avoids the potentially large intermediate result if the dimensions happen to be large. func...

9 years ago | 1

| accepted

Answered
ode numerical answer with euler-method
You do it for vectors pretty much the same way you would do it for scalars. The main difference would be that you need to accoun...

9 years ago | 1

Answered
Remove elements from cell array
E.g., result = cellfun(@(x,y)x(~ismember(x,cell2mat(y))),array1,toRemove,'uni',false);

9 years ago | 0

| accepted

Answered
Random number between 0 and the value of another variable
q = rand*(1-p);

9 years ago | 1

| accepted

Answered
Matrix product along one of the dimensions of 3D array
See this link for options: <https://www.mathworks.com/matlabcentral/answers/371421-how-to-multiply-n-matrices-without-a-for-l...

9 years ago | 1

Answered
Lotka-volterra with ode45
Problem may be stiff. Try ode15s instead.

9 years ago | 0

| accepted

Answered
Error using ode45
Incorrect number of arguments for the derivative function, and incorrect syntax within that function. E.g., function y=opd...

9 years ago | 0

| accepted

Answered
diag problem while substracting
It's just a display format thing. It means each number shown is actually multiplied by 1.0e-15 E.g., >> [1 2 3] ans ...

9 years ago | 1

| accepted

Answered
I want to create a binary matrix in matlab in which each element must be 4 bit. ??
Not sure what you really want. If you are looking for a character array of "bits" then you could use dec2bin. E.g., >> de...

9 years ago | 0

Answered
Add Column Data to Existing Data Array at Specific Locations MATLAB
Going on faith that this is not homework, e.g., assuming that your ind vector has the correct number of 0's and 1's to account f...

9 years ago | 1

| accepted

Answered
Disable automatic termination of mex functions
Not from within the mex function that I am aware of. When these errors occur in an API library routine, of course the routine d...

9 years ago | 0

| accepted

Answered
creating a matrix where the element of the second column is smaller than the element of the first column
E.g., n = largest number (e.g., 3) result = cell2mat(arrayfun(@(x)[ones(x,1)*x,(1:x)'],1:n,'uni',false)');

9 years ago | 0

Answered
always get 255 in sum
Variable P is likely class uint8. Assuming this is true, the summing is done as uint8 which clips at the highest value of 255 f...

9 years ago | 0

| accepted

Answered
How do I find independent equations from a system of linear equations?
See this link: <https://www.mathworks.com/matlabcentral/answers/108835-how-to-get-only-linearly-independent-rows-in-a-matrix-...

9 years ago | 0

Answered
How to create a function with multiple calculations
Create a file called triangle_area.m on your path (e.g. in your working directory) and inside that function have this code: ...

9 years ago | 0

Answered
How can i decode(unpack) an array of bits with a constant value?
Not sure what the "rule" really is for getting the bits. Maybe one of these? x = your vector L = your number result ...

9 years ago | 1

| accepted

Answered
Is it possible to use mat.h outside Matlab?
You can use it e.g. in an Engine application program as opposed to a mex routine. But even in the Engine application program yo...

9 years ago | 0

Answered
Normalizing columns: Does my function do the same as "normc"?
Yes, your algorithm matches normc (R2016b Win64): >> m m = -0.3223 0.4342 0.2442 0.0030 -0.3323 ...

9 years ago | 0

Answered
why calculation time become slow when I use mex file?
For linear algebra calculations, such as matrix*vector products, MATLAB actually calls a 3rd party highly optimized multi-thread...

9 years ago | 1

Answered
Is there a way to assign a value to multiple diagonals in a matrix?
E.g., for a square matrix: >> X = zeros(6,6) X = 0 0 0 0 0 0 0 0 0 0 ...

9 years ago | 2

| accepted

Answered
Solve equation of motion using ode45!
figure;plot(t,y(:,1));grid on figure;plot(t,y(:,2));grid on

9 years ago | 0

| accepted

Load more