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

fast 11 Jahre vor | 0

| akzeptiert

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

fast 11 Jahre vor | 0

| akzeptiert

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

fast 11 Jahre vor | 0

| akzeptiert

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

fast 11 Jahre vor | 0

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

fast 11 Jahre vor | 0

| akzeptiert

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

fast 11 Jahre vor | 0

| akzeptiert

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

fast 11 Jahre vor | 0

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

fast 11 Jahre vor | 0

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

fast 11 Jahre vor | 0

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

fast 11 Jahre vor | 0

| akzeptiert

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

fast 11 Jahre vor | 1

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

fast 11 Jahre vor | 0

| akzeptiert

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

fast 11 Jahre vor | 0

| akzeptiert

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

fast 11 Jahre vor | 0

| akzeptiert

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

fast 11 Jahre vor | 0

| akzeptiert

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

fast 11 Jahre vor | 1

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

fast 11 Jahre vor | 0

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

fast 11 Jahre vor | 0

| akzeptiert

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

fast 11 Jahre vor | 0

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

fast 11 Jahre vor | 2

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

fast 11 Jahre vor | 0

| akzeptiert

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

fast 11 Jahre vor | 0

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

fast 11 Jahre vor | 1

| akzeptiert

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

fast 11 Jahre vor | 0

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

fast 11 Jahre vor | 0

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

fast 11 Jahre vor | 0

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

fast 11 Jahre vor | 0

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

fast 11 Jahre vor | 0

| akzeptiert

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

fast 11 Jahre vor | 1

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

fast 11 Jahre vor | 0

Mehr laden