Answered
How can I move a point a known distance in the direction of another point in 3D?
There is no need for a |for| loop: A = rand(166, 3) * 100; B = rand(166, 3) * 100; AB = B - A; nAB = AB ./ sq...

9 years ago | 0

Answered
How do get past the first interation in this nested loop?
Use the debugger to step through your code line by line: <https://www.mathworks.com/help/matlab/matlab_prog/debugging-process-an...

9 years ago | 0

Answered
Sum down to one digit
num = 123456789; while num > 9 dec = 10 .^ (0:ceil(log10(num)) - 1); digits = rem(floor(num ./ dec), 10); ...

9 years ago | 1

| accepted

Answered
How to find average R value in an RGB image?
RGB = rand(640, 480, 3); avgRGB = mean(reshape(RGB, [], 3), 1)

9 years ago | 1

Answered
histcounts error in place of histc
What a pity that the handy |histc| is deprecated now. A = randi(5,1,15); [uniqA, ~, iA] = unique(A); N = histcounts(i...

9 years ago | 1

Answered
I'm a noob. Can anyone make this simpler or more efficient?
There is no need for parentheses in let_grade=('A'); Better: let_grade = 'A'; Repeated code is a source of bugs,...

9 years ago | 0

Answered
My plot does not show anything
Your plot does show anything. The only problem, is that you cannot see it. The variable |ea| and |n| is overwritten in each i...

9 years ago | 2

Answered
Please , how can I find the center and the radius of the inscribed circle of a set of points
Your example contains a small set of points only. Then a brute force approach can solve the problem in a bearable time: Create a...

9 years ago | 0

Answered
How to find interpolation of x in a function of y by using intrep1 ?
You are right: In this example the NaNs are treated as gaps, which are filled by a linear interpolation of the surrounding point...

9 years ago | 0

Answered
how to repeat a table of 3068x2 50 times, adding a specific number, in each iteration?
Maybe: X = rand(3, 2); % In your case (3068, 2) Result = zeros(3, 2, 50); for k = 1:5 % In your case 50 R...

9 years ago | 0

Answered
How to map a value of a vector into column number of a matrix?
A = [2, 4, 5]; B = zeros(10, 3); idx = sub2ind(size(B), A, 1:3); B(idx) = 1;

9 years ago | 0

| accepted

Answered
Setting up multiple EDIT TEXT boxes in gui by a single command
set([handles.edit1,handles.edit2,handles.edit3,handles.edit4], 'string', z); See: |doc set| in the first paragraph: set...

9 years ago | 1

| accepted

Answered
Index exceeds matrix dimensions. vmw = sqrt((y(2)-Wx)^2 +(y(4)-Wy)^2 +(y(6)-Wz)^2); plz help to solve this problem.
Your code has another problem: the calling of the integrator is inserted in the function to be integrated. Split this: func...

9 years ago | 0

Answered
In an assignment A(:) = B, the number of elements in A and B must be the same.Error in c (line 78) ids(i+1) = ids(i)+h/6*(k1+2*k2+2*k3+k4);
Use the debugger to examine the problem: dbstop if error Then run the code again. When it stops at the error, check the ...

9 years ago | 0

Answered
How can I write this statement without for-loop? I need the summation of this value over (x,y).
Start with writing an efficient loop. Is the output pre-allocated? rx = 2^r_x; sp = size(p_xkyk, 1); S = zeros(sp, s...

9 years ago | 0

Answered
looping though data structures of different sizes
dataC = cell(1, 1600); timeC = cell(1, 1600); for i = 1:1600 S = xml2struct(filename); timeC{i} =...

9 years ago | 0

| accepted

Answered
I need help, i keep getting index exceeds matrix dimensions error
The code cannot run for several reasons. A simplified version of the loop (avoid overdoing it with parenthesis): j = 0; ...

9 years ago | 0

Answered
how to exclude, or remove, input response from command history?
Do not use the command history for complicated user defined logging. This is not its purpose. If you want to log data, creating ...

9 years ago | 0

Answered
Is Visual Studio 2017 supported without patches by matlab 2018a?
Matlab R2018a has not been published yet. If users download and test the pre-release version, they accept the NDA and are not al...

9 years ago | 1

| accepted

Answered
Script file that sums values and checks against another vector?
x = HW1Rand; sumx = cumsum(x); % Calculate the sum once only n = [65 156 187 42]; Solution = nan(1, length(n))...

9 years ago | 0

Answered
how can I make a matrix from each row of an excel sheet data and save each matrix in to a folder
data = xlsread(FileName); Now |data| contains the numerical values of all columns. Now you want to save them as matrices ...

9 years ago | 0

| accepted

Answered
Can we use MATLAB examples code with our own data
Even the code for the assignment operator "=" is copyrighted by MathWorks. Of course you can use the results obtained by this op...

9 years ago | 3

| accepted

Answered
i am trying to write a function.
A small example code: function r = Calculate(a, b, c) switch nargin case 2 disp(a) disp(b) r =...

9 years ago | 0

| accepted

Answered
How do you initialize a nested function?
Usually for odes, it is my understanding that you give the input parameter an initial value before running the ode solver, so...

9 years ago | 0

| accepted

Answered
How do a generate a random matrix of just 1s and -1s
Concerning the title of the question: A = 1 - randi([0, 1], 5, 5) * 2 I do not understand "add each row or column which ...

9 years ago | 0

Answered
Remove specific entry in a cell array
animals = {'cat', 'dog', 'mouse', 'horse'}; animals = setdiff(animals, {'dog'}) This would allow to remove multiple elem...

9 years ago | 7

Answered
Why does ls add trailing space preventing output use as filename string?
|ls| is thought to display the contents of the directory in the command window. Use |dir| instead to construct a file name: ...

9 years ago | 0

| accepted

Answered
Error Attempt to execute SCRIPT join_function as a function:
The error message is clear: |join_function.m| is a script file and then it does not accept input arguments. Only functions do th...

9 years ago | 0

| accepted

Answered
Index exceeds matrix problem
Data = {'KA', ... 'KT', ... 'Zb2.Cd4t1R2', ... 'Zb2.Bd4t1R2', ... 'Zb2.Ard4t1R1', ...

9 years ago | 0

Load more