Answered
Finding common x values along with the corresponding y values.
[match, index] = ismember(x_exp, x_sim) result = y_sim(index(match)) A problem is the repeated value: x_exp = [1040; ...

7 years ago | 0

Answered
why the handle of subplot cann't used by other function?
This is not a correct observation. See: function main AxesH = subplot(2,3,4); subfun(AxesH); end function subfun(AxesH) ...

7 years ago | 1

| accepted

Answered
putting the answer in a matrices
With a loop: nA = (a ~= 0); nRow = size(a, 1); nCol = max(sum(nA, 2)); result = zeros(nRow, nCol); % Pre-allocation...

7 years ago | 1

| accepted

Answered
How to extract rgb values from images.
img = imread('2018_bridge_2.png'); % Find [237, 1, 12] pixels: red_pixel = nnz(img(:, :, 1) == 237 & ... img(...

7 years ago | 0

Answered
How can I remove double and single quotations from multiple large .csv files located in the same directory efficiently?
If you really want to modify the files: Folder = 'C:\Your\Folder' FileList = dir(fullfile(Folder, '*.csv')); for iFile = 1:...

7 years ago | 0

Answered
Concatinate the ith element of one matrix with the ith element of second matrix
Alternative: a = [1 2 3 4 5 6]; b = [10 11 12 13 14 15]; c = zeros(1, numel(a) + numel(b)); c(1:2:end) = a; c(2:2:...

7 years ago | 2

Answered
is it possible to calculate the given matrix without loops?
result = (R .* F.') * P % or result = R * (P .* F)

7 years ago | 0

| accepted

Answered
Importing and reading txt file in GUI
function pushbutton1_Callback(hObject, eventdata, handles) [filename, pathname] = uigetfile({'*.txt'},'File Selector'); if ~is...

7 years ago | 0

| accepted

Answered
Acces axes from other callback function in GUI - transfer data between functions
The problem is, that you create the callback before S is created completely: S.pb_calculate = uicontrol(S.figure,'style','push'...

7 years ago | 1

| accepted

Answered
extracting a particular element from a matrix
A bold guess: index = (A == max(A)); A(index) + B(index)

7 years ago | 0

Answered
How to count different value from 2 cell?
Fast: sum(strcmp(A, B))

7 years ago | 2

Answered
Linebreak between two txt-files in one txt-file.
Do you need the slow indirection over a system call? system('copy /b input1.txt + input2.txt output.txt') The code in Matlab ...

7 years ago | 0

| accepted

Answered
Reshape 4D matrix, keeping the 1st and 2nd dimensions intact
B = reshape(A, 144, 73, []); The result is a [144 x 73 x 17*1460] array.

7 years ago | 0

| accepted

Answered
How can i build a for loop for a subset of data having repetitions?
Maybe you want: k = unique(IDstop1); result = cell(1, numel(k)); for i = 1:numel(k) index = (IDstop1 == k(i)); ...

7 years ago | 1

| accepted

Answered
Is there a way to detect a defined interval of time between boolean states and if true, switch the boolean state within this interval?
The description is far too complicated. Actually you have a logical vector and want to remove blocks of TRUE (or FLASE?) is they...

7 years ago | 0

Answered
choose 2 index separately inside cell
index = {[1,2,5,9,10,13,17,18,21],[4,5,7,12,13,15,18,20,21],[3,4,6,11,12,14,18,19,20],[8,16,20,22]}; amount = {[10,11,12,10,11...

7 years ago | 0

Answered
One license for many users in the same computer
It depends on what kind of license you have. Because this is the public forum for discussions, I assume that it is better to ask...

7 years ago | 0

Answered
suggest me how to plot 45 degree line in MATLAB?
I guess, that you do get a 45 deg angle, but that the different scaling of X and Y axes let it look in another angle. See: axis...

7 years ago | 1

| accepted

Answered
Set zero in certain rows of an array to value x
A = [1 1 0 1 0 1;1 1 0 0 1 1; 1 1 0 1 1 1]; x = 1000000; % all zeros in row 2 and 3 to 1.000.000 match = (A == 0); m...

7 years ago | 0

| accepted

Answered
Cannot install MatLab on my Windows 10 Laptop
The message asks you to read: "For more information on resolving this issue, see https://www.mathworks.com/matlabcentral/answer...

7 years ago | 0

Answered
How to binarize the grayscale image in the attached grayscale.mat file
If a threshold satsfies your needs, use a threshold: Thresh = 5; X = (Img > Thresh); See your other question: https://ww...

7 years ago | 0

Answered
Count the occurence of a number in between other numbers
See Jos solution (link): D = diff(find(diff([false, x==0, false]))); R = D(1:2:end); A short test (yes, I know that timeit is...

7 years ago | 1

Answered
find length NaN segments
And again: With FEX: RunLength : [B, N] = RunLength(A); Result = N(isnan(B)); Or: y = [false, isnan(A), false]; Result...

7 years ago | 1

Answered
Count the occurence of a number in between other numbers
Another solution: x = [ 1 0 0 1 1 1 0 1 1 0 0 0 0 0 1 1 0 1 0]; y = [1, x, 1]; strfind(y, [0,1]) - strfind(y, [1,0])

7 years ago | 3

Answered
How to avoid having duplicate index result?
If I assume, that this code satisfies your needs for 1 call: x = zeros(4, 4); x(sub2ind(size(x), 1:4, randperm(4,4))) = 1; I ...

7 years ago | 0

Answered
How to convert UTC timestamp to unix time in MATLAB with the respect of leap seconds
It depends on how the unix time stamps are created. Actually unix time and UTC is synchronized. Then computers writing time stam...

7 years ago | 1

Answered
Display figure returned by .m function into GUI axis
"setting a figure returned by a .m file into matlab guide axis" - this is not clear yet. I guess the "m file" is the function El...

7 years ago | 1

Answered
Conversion from unix time string to uint64
The conversion by str2double creates a double, which uses 53 bits only. With sscanf you can get 64 significant bits to store the...

7 years ago | 0

| accepted

Answered
Matlab for research purpose
Code published in the FileExchange is covered by the BSD license. Simply read the included file to see, how to include the code:...

8 years ago | 0

| accepted

Answered
How can I split a text file into many files?
S = fileread('YourFile.txt'); C = strsplit(S, char(10)); ini = find(strncmp(C, 'STARTSEC ', 9)); fin = find(strncmp(C, 'ENDSE...

8 years ago | 0

Load more