Community Profile

# Benjamin

Last seen: Today Active since 2013

All

#### Content Feed

View by

Calculate average between min and max numbers in column 3 depending on values in column 2, for each value in column 1
matrix = randi([1 16],2000,3); search_number = 7; idx_1 = matrix(:,1) == search_number; col2_vals = unique(matrix(idx_1...

ungefär 4 timmar ago | 1

Find the Minimum Combination of Sum
N = 100; window_size = 3; A = rand(N,1); signs = 1-2*(dec2bin(0:2^(window_size-1)-1,window_size)-'0').'; comb = NaN(N,1)...

ungefär 6 timmar ago | 1

| accepted

Getting "Index exceeds array bounds" for line 103 but I do not see how the index number is more than the elements. Any help would be awesome!
Assuming output is an n-by-6 cell array, length(output) will be n if n >= 6 and 6 otherwise (i.e., if n < 6). Note that length()...

ungefär 10 timmar ago | 0

Why won't this function plot?
Try plot(c1_exp) or plot(t,c1_exp) With your for loop, you're plotting one data point at a time, which is imposs...

ungefär 23 timmar ago | 0

How do I convert a frequency table to a single vector?
First, setting up the variable as you have it: Blank2 = zeros(23,2); Blank2(:,1) = 1:23; Blank2(3,2) = 1; Blank2(4,2) = 8; ...

en dag ago | 0

| accepted

Create push buttons with a For loop and provide individual callbacks within the For loop.
When you specify a callback as a character vector, the callback executes in the MATLAB workspace (reference here), which may or ...

en dag ago | 0

| accepted

Split a vector into 2 oscillating vectors?
Here is a way to do it. Demonstrating with smaller vectors so as to more easily verify the result. To use it on your column vect...

en dag ago | 0

| accepted

For Loop Question on index
data = [ ... 1.0 68.0 45.0 92.0; ... 2.0 83.0 54.0 93.0; ... 3.0 61.0 67.0 91.0; ... 4.0 70.0 66....

en dag ago | 0

| accepted

How can I randomize positions with retract/replacement and save in a text file?
It sounds like you want a 30-by-40 matrix where each element is one of {20,40,60,80,100,120,140} and no two adjacent elements on...

en dag ago | 0

| accepted

How to replace the numbers in matrix?
Here is a way to do it using linear interpolation on each row. It will interpolate between the non-zero numbers to fill in the z...

en dag ago | 1

| accepted

How to display sequence of images in GUI
This line: img_files = num2str((1:seq_len)', [img_path '%04i.jpg']); should be like this: img_files = strcat(img_path,num2str...

en dag ago | 0

I dont understand, i try to use solve to find x in Matlab Function Block
Looks like you should use syms rather than sym fcn(0) function x = fcn(y) syms a; r1=7.3e-5; r2=-1.1e-7; s1=1.6e-1; s2=1....

2 dagar ago | 0

adding limits in scatter plot
line([min(X) max(X)],[3100 3100]);

2 dagar ago | 0

| accepted

how to create a matrix when using surf function？
What you are doing there is making F a scalar, but F needs to be a matrix the same size as u and v, so something like this: F =...

2 dagar ago | 0

How to export matrix in the form of (column number, row number, value) in CSV?
A = randn(8,4) [m,n] = size(A); [c,r] = meshgrid(1:n,1:m); writematrix([c(:) r(:) A(:)],'output.csv'); % check the result ...

2 dagar ago | 0

| accepted

Creating different types of arrays with conditions, then make an array with the combination of all elements, and finally separate the arrays with a sequence
x = 3; y = 4; a = 1000*(1:x).'+(1:y) A = a(randperm(x*y)) [~,idx] = ismember(A,a); [~,new_idx] = sort(mod(idx-1,x)+1); a_n...

2 dagar ago | 0

| accepted

How do I extract a vector from a single field in a structured variable?
Maybe this? folder_names = struct('name',{'a','bb','ccc'}) participant_ID = {folder_names.name}

2 dagar ago | 0

Number of rows based on frequency of one integer and position of another integer
Get the set of unique numbers in the 2nd column: col2_vals = unique(matrix(:,2)); The 5th highest is 4th from the end. S...

2 dagar ago | 0

| accepted

How to display arc length of the line created on a line plot based on the input data
% some x and y: x = [10:-1:2 2:10]; y = [5+sqrt(x(1:end/2)) 5-sqrt(x(end/2+1:end))]; plot(x,y,'-o'); set(gca(),'XLim',[0 12]...

2 dagar ago | 0

| accepted

Create a new table from a plot constructed from data points
% a table with 1000 rows: t = table((1:1000).',2*(1:1000).'+100,'VariableNames',{'x' 'y'}) % user-defined interval over x: x_...

2 dagar ago | 0

Y data addition on scatter plot
You need to convert those cell arrays to numeric matrices before you can plot them (scatter or otherwise): X= { 2 ,3,4,5} Y={ ...

2 dagar ago | 0

| accepted

Determine the current position of an object in the context of drag and drop
Basically, in the motion function and button up function, you have to check whether dragging is an element of a or of b and set ...

2 dagar ago | 0

| accepted

How to improve calculation time for a huge matrix?
The original method but with SS = 5 to reduce the time (takes ~3.5 seconds): tic syms Q1 Q2 D3 EndEffectorVariables (Q1,Q2,...

2 dagar ago | 0

| accepted

Random sized hexagones in a hexagone grid
The problem is here: Rcore = rand(size(Xh))*range(bounds)+bounds(1); R1core = rand(size(Xl))*range(bounds)+bounds(1); Those a...

3 dagar ago | 0

| accepted

Error using feval and Invalid function name
You can use an anonymous function, e.g., f = @(x)x/56, or a named function, rather than a character array (f = 'x/56') for feval...

3 dagar ago | 0

| accepted

Stopping a for loop when certain values have been reached
values = []; n_tries = 1000; for i = 1:n_tries values(i) = randi(9); if all(ismember(1:9,values)) break ...

3 dagar ago | 0

| accepted

how can i split mtrix to three ?
Here is one possible way, if A is your matrix: A1 = A(1:51,:); A2 = A(52:102,:); A3 = A(103:153,:);

3 dagar ago | 0

How do I pass variable from one function to another
How about this? function [v] = Popup(obj, handles , h_listbox) parameters=detectImportOptions('Data.xlsx'); ...

3 dagar ago | 0

| accepted