Respondida
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 = ...

más de 10 años hace | 0

| aceptada

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

más de 10 años hace | 0

| aceptada

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

más de 10 años hace | 0

| aceptada

Respondida
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:...

más de 10 años hace | 0

Respondida
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)...

más de 10 años hace | 0

| aceptada

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

más de 10 años hace | 0

| aceptada

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

más de 10 años hace | 0

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

más de 10 años hace | 0

Respondida
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')

más de 10 años hace | 0

Respondida
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) ...

más de 10 años hace | 0

| aceptada

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

más de 10 años hace | 1

Respondida
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'}; ...

más de 10 años hace | 0

| aceptada

Respondida
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]...

más de 10 años hace | 0

| aceptada

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

más de 10 años hace | 0

| aceptada

Respondida
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']

más de 10 años hace | 0

| aceptada

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

más de 10 años hace | 1

Respondida
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; ...

más de 10 años hace | 0

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

más de 10 años hace | 0

| aceptada

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

más de 10 años hace | 0

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

más de 10 años hace | 2

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

más de 10 años hace | 0

| aceptada

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

más de 10 años hace | 0

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

más de 10 años hace | 1

| aceptada

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

más de 10 años hace | 0

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

más de 10 años hace | 0

Respondida
Plot vectors in matlab as a straight line
plot(T, r)

más de 10 años hace | 0

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

más de 10 años hace | 0

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

más de 10 años hace | 0

| aceptada

Respondida
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));

más de 10 años hace | 1

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

más de 10 años hace | 0

Cargar más