Answered
Calculate angle between vectors
See: https://www.mathworks.com/matlabcentral/answers/16243-angle-between-two-vectors-in-3d The actual numerically stable formu...

4 years ago | 0

Answered
whats wrong with this function?
Which inputs are you using? If e.g. best_salt_1 is not one of the options of the first switch block, the output of [] is expecte...

4 years ago | 0

Answered
My matlab is not recognizing HEXA values
Your observation is correct. Before version 2019b hexadecimal and binary values are not recognized by Matlab and a leading 0x or...

4 years ago | 0

| accepted

Answered
facing problem in reshaping the column matrix please help
Maybe you mean: n = 3; E = zeros(n+1, 1); % Pre-allocate in wanted dimension instead of reshape ee = zeros(n+1, n+1, n+1); ...

4 years ago | 1

Answered
how to calculate cauchy product in summation
The shown code cannot run. In the 1st iteration of the "for i" loop, the inner loop is not entered: "for p = 1:i-1". In the 2nd ...

4 years ago | 0

Answered
How do you elegantly load dynamic variables into a cell array?
Avoid eval. Instead of eval(sprintf("out.%s.Data","A1")) this is faster, safer and nicer: out.('A1').Data Then the loop beco...

4 years ago | 0

| accepted

Answered
find the location of a vector in a cell array and extract the last element of that vector
Why do you store the vectors in such a complicated format? Creating one [M x 3] matrix would help to create an easy solution: A...

4 years ago | 1

| accepted

Answered
Is there a keyboard shortcut for deleting one character ahead of the cursor, instead of one character behind it?
Usually this is done by the delete key.

4 years ago | 1

| accepted

Answered
Translate vector to a center point
At first simplify AB = [(A(:,1)-B(:,1)), (A(:,2)-B(:,2)), (A(:,3)-B(:,3))]; BC = [(C(:,1)-B(:,1)), (C(:,2)-B(:,2)), (C(:,3)-B(...

4 years ago | 0

Answered
How to delete even Index from array and replace zero at the end MATLAB
"delete even index sample from the array and add zero at the end" Maybe: X = rand(10, 10); % Arbitrary test data ...

4 years ago | 0

| accepted

Answered
How do I make a cell array of doubles with non-uniform dimensions into a matlab array? (substitution of blanks with NaN or Zero)
Another hint to save time: cellfun is less efficient than a loop: data = {'[700 900]';'[700 900 1050 800]';'[700]'}; data = re...

4 years ago | 1

| accepted

Answered
Why using interp2 gives NaN
interp2() replies NaNs, if the interpolated points are outside the given set of points, so it is a "extrapolation". So stop the ...

4 years ago | 0

| accepted

Answered
ismember or setdiff but with different number of columns
A = [8,6,7]; B = [1,6,9; 3,5,4; 7,0,2]; M = ismember(B, A) C = find(any(M, 2))

4 years ago | 1

| accepted

Answered
Hello, I am trying to solve the ODE but I have an error I do not understand how to solve. Would appreciate some help. Thank you!
Omit the "@(x)" in: dxdt = @(x) [q - (thrust*sin(alpha+epsilon) + L)/(mass*u) + g/u*cos(theta-alpha); ... % ^^^^ ...

4 years ago | 0

| accepted

Answered
efficient variable circshift on 3D matrix
In this code: s = size(A); a = reshape(A, [], s(3))'; b = reshape(B, [], 1); ub = unique(b); for i = 1:numel(ub) m ...

4 years ago | 0

| accepted

Answered
Installed the 2007 teaching version of MATLAB, but the following window appears
The error message means, that the device for reading the installation data cannot access the file "mwinstall.dll". Now please me...

4 years ago | 0

Answered
why is showing Inf and Nan value how to remove that
Your function is growing exponentially. It is the mathematically correct behaviour, that it reaches Inf. "Fixing" this would mea...

4 years ago | 0

Answered
How to improve my inefficient code?
This is a first point to start from: load 'data' Calling load without catching the output creates variables dynamically. This ...

4 years ago | 2

Answered
Draw a straight line on a gray image and calculate the sum of the gray values on the straight line
This is a job fpr improfile .

4 years ago | 0

| accepted

Answered
Can Matlab read the most recent made file in the default folder?
A summary of the comments: d = dir('somefolder/*txt'); [~, index] = max([d.datenum]); youngestFile = fullfile(d(...

4 years ago | 1

| accepted

Answered
Index exceeds the number of array elements. Index must not exceed 0.
This is strange: MaxEmDim = size(Portrait) *[0;1]; Nopoints = [size(xnew)*[1;0] size(xnew)*[1;0] size(xnew)*[1;0]] Use size(X...

4 years ago | 0

Answered
How do i read 60 .txt files into matlab?
Some hints: Omit the clear all . It wastes time and has no benefit. It removes all loaded functions from the memory and relaodi...

4 years ago | 0

Answered
Unable to load multiple mat files
This does not match: S = struct([]); for i=1:numel(theFiles) S{i} = ... You define S as a struct, but then you creat...

4 years ago | 0

Submitted


strncmpr
Compare last N chars of strings or cell strings (fast C-Mex)

4 years ago | 1 download |

0.0 / 5

Answered
I want to implement all possible 2*2 or 3*3 or n*n matrices by using 0 or/and 1 as their elements.
n = 3; M = rem(uint8(floor((0:2^(n*n)-1) .* pow2(0:-1:1-n^2).')), 2); M = reshape(M, n, n, []); M(:, :, 1) M(:, :, 2) M(:, ...

4 years ago | 1

| accepted

Answered
How do I add 0 after every value in a vektor
This works without a loop. v = [3,5,2,7]; Now append a 2nd row with zeros: v = [v; zeros(size(v))]; % Or equivalently: v(2,...

4 years ago | 0

Answered
How to read xlsx file with displayed precision of decimals
The problem is not trivial. Notice that e.g. "3.50" can have the stored value "3.4999999999999999". This is smaller than 3.5, bu...

4 years ago | 0

Answered
Multiplying two vectors to form a matrix
z = sqrt(x .^ 2 + y.' .^ 2) But, of course, this does not match "multiply them". If you want a multiplication: x .* y.' [ED...

4 years ago | 0

| accepted

Answered
how to remove columns from a 3D array, considering user input
Either use square brackets for the input: b = input('Indices enclosed in square brackets: '); % Type in: [1,5,7] Or input a s...

4 years ago | 0

| accepted

Answered
how to do a for cycle for cell arrays
And the next question concering indices hidden in the names of variables. Use an array instead. In your case, data2 is sufficie...

4 years ago | 0

| accepted

Load more