Risposto
Problem when Indexing large integer arrays
This [v(end):-1:v(1)] creates an indexing array that starts at the value v(end), increments by -1, and ends with v(1). It doe...

quasi 6 anni fa | 0

| accettato

Risposto
dot product between two different size of matrix
Assuming everything is real and by "dot product" you aren't involving complex conjugates, simply this C = B * A';

quasi 6 anni fa | 1

Risposto
Multiply one dimension of a 3D Matrix by a vector
C = A .* reshape(B,1,1,[]); For earlier versions of MATLAB that do not have implicit expansion it would be this: C = bsxfun(@t...

quasi 6 anni fa | 0

| accettato

Risposto
Graph Method Root Finding
E.g., x = -1:0.01:1; % pick some x range to look for a root plot(x,x-2.^(-x)) % plot the equation grid on or fplot(@(x)x-2....

quasi 6 anni fa | 0

Risposto
covert 128 binary string into hex decimal
b = your binary digits vector d = [8 4 2 1]*reshape(b,4,[]); h = sprintf('%x',d);

quasi 6 anni fa | 3

| accettato

Risposto
How to use the three points A1, A2, and B0 to calculate ∠A1B0A2?
A1 = [171 422] ; A2 = [415 413] ; B0 = [277 386] ; d1 = A1-B0 ; d2 = A2-B0 ; theta = atan2( norm(cross([d1 0],[d2 0])), dot...

quasi 6 anni fa | 0

Risposto
set order of elseif
Does this do what you want: order = [1 2 3]; % or whatever for k=1:numel(order) switch order(k) case 1 if( ...

quasi 6 anni fa | 0

| accettato

Risposto
Fields within Cell structures.
E.g., to sort everything by mpg: [~,x] = sort([Car.mpg]); CarMpg = Car(x); To pick off only those with certain constraints, e...

quasi 6 anni fa | 0

Risposto
Convert 32 bit image to 8 bit image
I'm assuming you just need to scale things. E.g., X = your image (as a unit32?) Y = uint8( double(X) * ((2^8-1)/(2^32-1)) ); ...

quasi 6 anni fa | 1

Risposto
Hex 01A9 to 16-binary?
E.g., if H is not too big: H = '01A9'; B = dec2bin(hex2dec(H),numel(H)*4) Otherwise you will need some form of a loop (explic...

quasi 6 anni fa | 0

Risposto
Why getting this error??
Don't shadow the MATLAB min() and max() functions with variables of the same name. Also min() and max() operate on columns by d...

quasi 6 anni fa | 1

Risposto
Help me with this task using (Euler`s method)
The function handle is something you only need to create once, before the for-loop starts. Then call that function handle with ...

quasi 6 anni fa | 1

| accettato

Risposto
Cell Arrays and loops
A cell array uses the curly braces. E.g., MyNames = {'ThisName','ThatName','OtherName'}; The number of elements is simply nume...

quasi 6 anni fa | 0

| accettato

Risposto
How to write a function handle in vectorized form and avoid an error due to lengthy equation
Your post is inconsistent since it appears to need an even number of columns but you end your example with column 100001, an odd...

quasi 6 anni fa | 0

| accettato

Risposto
Why does NO ODE function work??
Did you download the code for ode1 from the link provided? https://www.mathworks.com/matlabcentral/fileexchange/54611-solving-o...

quasi 6 anni fa | 0

Risposto
Help with creating a for loop
You could take this approach: A = your matrix AA = A*A'; % all of the dot products between rows (more than you need, actually)...

quasi 6 anni fa | 0

Risposto
Inexplicable different execution speeds when filling a matrix with complex entries
When an array switches from real to complex in R2018a or later, a new memory allocation and deep data copy must occur to change ...

quasi 6 anni fa | 0

Risposto
Error in fzero for solving numerical inverse function
These lines don't do what you think they do syms x g = 1.02*x + 0.6*exp(-8.7*x)-0.292 gx = @(x) g The x in g is symbolic. T...

quasi 6 anni fa | 1

Risposto
Code not coming out of if statement.
Sorry for the late reply ... I just saw this post. These lines f1 = @(y) g - sign(y).*cd/m.*y.^2; f2 = @(y) g - sign(y).*(cd...

quasi 6 anni fa | 0

Risposto
Runge kutta 4th order
You are using k(j) in your derivative function handles. This is a mistake since it causes the function handles to use the curre...

quasi 6 anni fa | 0

| accettato

Risposto
How to move elements of vector
Could use a loop on the rows with logical indexing. E.g., vec = whatever z = (vec == 0); for r=1:size(vec,1) vec(r,:) = ...

quasi 6 anni fa | 1

| accettato

Risposto
Creating vector and matrix from vector
Element-wise multiplication is done with the .* operator (with the dot). E.g., data = Xtrain .* Ytrain; The operation data(:) ...

quasi 6 anni fa | 0

| accettato

Risposto
How to fill a 3D zeros matrix array
One way: c = arrayfun(@(a)[cos(a), sin(a), 0; -sin(a), cos(a), 0; 0, 0, 1],Tho_t,'Uni',false); result = cat(3,c{:}); Your for...

quasi 6 anni fa | 0

| accettato

Risposto
plotting one variable function
Your question is unclear. Is it Ri that varies from 2 to 25? And the y-axis and x-axis formulae you have are the coordinates o...

quasi 6 anni fa | 1

Risposto
Trying to make a piecewise function that isn't for graphing or using the piecewise function itself
Use logical indexing on both sides of the assignment. E.g., function y = project2Tester(x) y = zeros(size(x)); x1 =...

quasi 6 anni fa | 0

| accettato

Risposto
Reshape an Matlab array
A straightforward assignment: A = zeros(7,24); A(:,1:2:end) = reshape(RELOADING_PATTERN(:,1),7,12); A(:,2:2:end) = reshape(RE...

quasi 6 anni fa | 0

| accettato

Risposto
Why won't my while loop terminate?
The forceErr you are calculating happens for every iteration of the for-loop. The forceErr that the while-loop sees is only for...

quasi 6 anni fa | 0

Risposto
Issue with Mexfile in parfor loops
Regarding the inplace modification in MATLAB, here is the actual situation: MATLAB uses a system behind the scenes that is ofte...

quasi 6 anni fa | 0

Risposto
Dice with changed probabilites
0.8% is the probability of getting three 3's in a throw of three dice. It is not the probability of the number of three 3's in ...

quasi 6 anni fa | 1

| accettato

Carica altro