Beantwortet
how to save values in a matrix from a loop
A completely different approach: x = [2 2 2 3 3 5; 6 6 5 5 5 7]; nRow = size(x, 2); y = cell(1, nRow); % Pre-allocate:...

mehr als 4 Jahre vor | 1

Beantwortet
Why am I getting an out of index error?
What is x1? The error message means, that it has 2 elements only, but you request x1(3). Your function handle takes the input x...

mehr als 4 Jahre vor | 0

Beantwortet
high pass filter of IIR
What is n? %X = cos(20*pi*5*n*1/100) - sin(pi*2*n*1/100); %Y2 = 0.765*X - 1.53*(X-1) + 0.765*(X-2) + 1.475*(Y2 - 1) - 0.587*(Y...

mehr als 4 Jahre vor | 0

Beantwortet
identify consecutive occurrence of 1 in a binary array
A = [0,0,0,0,1,1,0,0, ... % Using a row vector instead 1,0,1,1,1,1,0,0, ... 0,1,1,0,1,0,0,1]; % Find longest r...

mehr als 4 Jahre vor | 0

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

mehr als 4 Jahre vor | 0

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

mehr als 4 Jahre vor | 0

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

mehr als 4 Jahre vor | 0

| akzeptiert

Beantwortet
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); ...

mehr als 4 Jahre vor | 1

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

mehr als 4 Jahre vor | 0

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

mehr als 4 Jahre vor | 0

| akzeptiert

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

mehr als 4 Jahre vor | 1

| akzeptiert

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

mehr als 4 Jahre vor | 1

| akzeptiert

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

mehr als 4 Jahre vor | 0

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

mehr als 4 Jahre vor | 0

| akzeptiert

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

mehr als 4 Jahre vor | 1

| akzeptiert

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

mehr als 4 Jahre vor | 0

| akzeptiert

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

mehr als 4 Jahre vor | 1

| akzeptiert

Beantwortet
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); ... % ^^^^ ...

mehr als 4 Jahre vor | 0

| akzeptiert

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

mehr als 4 Jahre vor | 0

| akzeptiert

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

mehr als 4 Jahre vor | 0

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

mehr als 4 Jahre vor | 0

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

mehr als 4 Jahre vor | 2

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

mehr als 4 Jahre vor | 0

| akzeptiert

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

mehr als 4 Jahre vor | 1

| akzeptiert

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

mehr als 4 Jahre vor | 0

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

mehr als 4 Jahre vor | 0

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

mehr als 4 Jahre vor | 0

Gesendet


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

mehr als 4 Jahre vor | 1042 Downloads |

0.0 / 5

Beantwortet
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(:, ...

mehr als 4 Jahre vor | 1

| akzeptiert

Beantwortet
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,...

mehr als 4 Jahre vor | 0

Mehr laden