Réponse apportée
detecting no. of events
If D contains an entry every second, you can use: D = randi(2000, 1, 20); % sample data di = diff([0 D > 25 0]); i1 = ...

plus de 10 ans il y a | 0

| A accepté

Réponse apportée
Matlad read csv file and euclidean distance
X = csvread('yourfile.csv'); X(:,1) = []; % delete first column

plus de 10 ans il y a | 0

| A accepté

Réponse apportée
How can calculate this formula with matlab?
You can pull the w_i and sigma_i outside of the sum_j, because the don't depend on j. And you can compute the sum_j nicely as a ...

plus de 10 ans il y a | 0

| A accepté

Réponse apportée
Ho to enter this equation and plot it
I'm not sure what you want, but if you want to evaluate y for every combination of x and w on a 2D grid, you can use: x=10:...

plus de 10 ans il y a | 0

Réponse apportée
How to make coodinates bounce off the screen edge
You have to make the following changes to your code # test x and y coordinates separately using Coords_1(1) and Coords_1(2)...

plus de 10 ans il y a | 0

| A accepté

Réponse apportée
i can get the equation to give a matrix 82x96
f takes values 1, 1.2, 1.4, ... 20, and you try to use f as subscript P(f) which is not allowed. You can use fve...

plus de 10 ans il y a | 0

| A accepté

Réponse apportée
read date from character string
This works if there is always the string "_L2_" right before the date: i1 = strfind(filename, '_L2_')+4; datenum(filename(...

plus de 10 ans il y a | 0

Réponse apportée
how can i prevent bogus values while executing a loop consist of variables?
Have you checked the value of sumB before the loop? Maybe you assume sumB to be 0 but it is not from a previous run of the loop....

plus de 10 ans il y a | 0

Réponse apportée
How to set legend for a line segment?
x1 = 10; x2 = 20; y1 = 12; y2 = 34; line([x1 x2],[y1,y2],'color','r','linestyle','--'); legend('my dashed red line')

plus de 10 ans il y a | 0

Réponse apportée
How do I sort an array in descending order without using the sort function?
You can use bubble sort: swapped = 1; while swapped swapped = 0; for i=1:numel(A)-1 if A(i+1) > A(i) ...

plus de 10 ans il y a | 0

| A accepté

Réponse apportée
Can anybody help me to explain the logic behind bwdist matlab function. thanks
B is a binary image, i.e., an image that contains only 0's and 1's. For every pixel in B, bwdist computes the distance to the ne...

plus de 10 ans il y a | 1

Réponse apportée
Cannot run a word-stimulus perception experiment
stim = V(i,:); To be more flexible you can use cells to store words of different length: V = {'me' 'you' 'others'}; ...

plus de 10 ans il y a | 0

| A accepté

Réponse apportée
How to combine signals for each digit in telephone number (dtmf) to form one continuous signal?
Set y = []; silence = zeros(1,numel(time_vector); before the for loop and then use y = [y y_high+ y_low silence]...

plus de 10 ans il y a | 0

| A accepté

Réponse apportée
Multiply Image with a mask
You can convert the mask to uint16: X = uint16(2^16*rand(10)); % sample image M = zeros(size(X)); M(4:6, 6:8) = 1; % creat...

plus de 10 ans il y a | 0

| A accepté

Réponse apportée
How to use variables as filename when saving to a .csv file
output_filename = [datestr(datenum(start_date), 'yyyy-mm-dd') ' -- ' datestr(datenum(end_date), 'yyyy-mm-dd') '--data.csv']

plus de 10 ans il y a | 0

| A accepté

Réponse apportée
How to write a program in Matlab which takes as input a student’s grade (such as ‘81’) and return a new grade in the A,B,C etc scale?
grad = input('Grad> ') if grad >= 90 newgrad = 'A-'; elseif grad >= 87 newgrad = 'B+'; elseif ... or wr...

plus de 10 ans il y a | 1

Réponse apportée
How do I make a cell array of doubles with non-uniform dimensions into a row numeric array? (not a column numeric array)
To write all of your data into a single matrix, you can use Npeaks = numel(locs_max); Ndata = locs_max - locs_min + 1; ...

plus de 10 ans il y a | 0

Réponse apportée
make some matrices from one matrix without repeating the same numbers
Using B= randi(1000,[1 200]) you don't get 200 unique numbers. If your goal is to split the numbers from 1 to 1000 in random or...

plus de 10 ans il y a | 0

| A accepté

Réponse apportée
Logical indexing of cell array
I tried it with your variables and it worked fine. >> size(old_cell_array) ans = 196.00 1.00 >> n...

plus de 10 ans il y a | 0

Réponse apportée
Reducing a matrix size by averaging blocks within the matrix.
fun = @(block_struct) mean(block_struct.data(:)); Y = blockproc(X, [2 2], fun)

plus de 10 ans il y a | 2

Réponse apportée
Parfor performance are too good to be true
1. I guess the code is optimized, such that, e.g., the for loop is replaced by z = z + 200; 2. That's valid, because the com...

plus de 10 ans il y a | 0

| A accepté

Réponse apportée
preserving variable class when extracting fields from a struct
fn = fieldnames(S); for i = 1:numel(fn) eval([fn{i} '= getfield(S, ''' fn{i} ''');']) end But instead I would r...

plus de 10 ans il y a | 0

Réponse apportée
Combine legends of two plots (Two plots are in a for loop)
You cannot "add" an entry to an existing legend, as far as I know. But you can create handles for you plots and concatenate the ...

plus de 10 ans il y a | 1

| A accepté

Réponse apportée
How to add text to an image
The text function just draws the text into the image at position x,y. The default text color is black. So if you want to draw te...

plus de 10 ans il y a | 0

Réponse apportée
How to stop a simulation if condition is true
Put all code after end into the else clause of the if. If the if is within a loop, add a break after the display.

plus de 10 ans il y a | 0

Réponse apportée
Plot vectors in matlab as a straight line
plot(T, r)

plus de 10 ans il y a | 0

Réponse apportée
How to take text files and turn the data into variables?
The data file just contains comma separated values, you can use dlmread. For more complicated data, textscan is fine, as Star St...

plus de 10 ans il y a | 0

Réponse apportée
How to make a new folder within another folder?
Just use one argument: mkdir(newsubfolder); And in the for fileidx = 1 : length(fileinfo) loop, get rid of the lines ...

plus de 10 ans il y a | 0

| A accepté

Réponse apportée
How do I write a function that contain a for loop to go through my filesname to find a match?
It a one-liner; your probably do not want to write a function for it nol = numoflike_list(strcmp(image_name, name_list));

plus de 10 ans il y a | 1

Réponse apportée
Finding a letter or number in a string of cells
C = {'Brad1', 'Bobby2', '1Bob', '2Bradley', '2Bailey'} f1 = C(~cellfun(@isempty, strfind(C, '1'))) f2 = C(~cellfun(@isempty...

plus de 10 ans il y a | 0

Charger plus