Réponse apportée
How to create a grid of evenly spaced ones in a matrix of zeros?
"Is there a more compact or straightforward way to achieve this?" Definitively! %demo data size_array = 500; npoints = 15; ...

presque 7 ans il y a | 0

| A accepté

Réponse apportée
Random string generation of message
function out_str = rand_string_gen(np, str) out_str = regexprep(str, '.(?!$)', sprintf('$0${char(randi(double(''az''), 1, %...

presque 7 ans il y a | 0

Réponse apportée
How can I set x=1.1 with 30 decimal precision?
When you do x = 1.1 You create an x of class double. double numbers have a decimal precision of around 16 significant digits. ...

presque 7 ans il y a | 1

Réponse apportée
splitvars for input arguments of type 'cell'
As per my comment to your other question, it looks like Multico should be a matrix not a cell array. Regardless of its type, wh...

presque 7 ans il y a | 0

| A accepté

Réponse apportée
Filter contents of a table
Any reason why Multico is a cell array? If all the cells are just scalar, then it's a waste of memory and complicates the code f...

presque 7 ans il y a | 1

| A accepté

Réponse apportée
Sliding window function over column vector, Help!
"The data has months 7 to 10 and labelled them as M7, M8, M9, M10 to help me remember the months." Do not do that! Numbered var...

presque 7 ans il y a | 0

Réponse apportée
How to decrease run time in swap operation ?
What's the purpose of the while loop since you know beforehand when it ends and thus how many steps it will do? Assuming that f...

presque 7 ans il y a | 0

Réponse apportée
Group the array with similar strings
It's very unclear what your definition of similar is. Also note that your example A is a char vector, not a string, and that co...

presque 7 ans il y a | 1

| A accepté

Réponse apportée
Organize Excel date and time data
It's trivial to sort if you read the data in a table or a timetable: data = readtable('Practice.xlsx', 'ReadVariableNames', fal...

presque 7 ans il y a | 0

Réponse apportée
Counting consecutive repeat values for each row in matrix
It's a job for the image processing toolbox, in particular bwconncomp (with a custom connectivity): cc = bwconncomp(~yourphoto,...

presque 7 ans il y a | 1

Réponse apportée
Calculate connected graph components of "merged graphs" (graph union)
Assuming you want that identical nodes are nodes with the same X and Y coordinates, then first I'd add these coordinates to the ...

presque 7 ans il y a | 1

| A accepté

Réponse apportée
How to arrange time series data into yearly groups?
A simpler and faster way of obtaining the same as Joe's answer: dataInitial = readtimetable('Data.xlsx'); dataFinal = table(da...

presque 7 ans il y a | 0

| A accepté

Réponse apportée
Using strrep for matrix
Keeping your 2d character array as is: yourarray(ismember(yourarray, 'hood', 'rows'), :) = []; or yourarray(all(yourarray == ...

presque 7 ans il y a | 0

Réponse apportée
How to check whether any two elements are equal or not in a Nx1 array in matlab?
x = [1 2 3 4 2 5 6 3 7 8 9 10]; %demo data. Works with column or row vectors [loc1, loc2] = find(tril(x == x.', -1)); %loca...

presque 7 ans il y a | 2

| A accepté

Réponse apportée
Average of two consecutive rows and importantly average of first and last row.
You have to be careful with the terminology you use. structures aren't tabular, they don't have columns and rows (well, they can...

presque 7 ans il y a | 0

Réponse apportée
Strip comments from code read from file identifier
The only way to do this is to write a parser that can parse whichever language you're planning to support. At the very least, yo...

presque 7 ans il y a | 0

Réponse apportée
Accessing field data in nonscalar structure array
This is one of the reason I dislike multilevel structures (the other being they're very inefficient memory-wise), there's no eas...

presque 7 ans il y a | 2

Réponse apportée
Using Matlab to Organize Excel Data into Separate Columns
It's trivial to do with unstack: demodata = table(repelem({'Object1'; 'Object2'}, 3), repmat({'X'; 'Y'; 'Z'}, 2, 1), rand(6, 1)...

presque 7 ans il y a | 1

| A accepté

Réponse apportée
Have data in subfolders available
Firstly, it's not a good idea to mix code and data folder. The two should be completely separate, so that your code can work reg...

presque 7 ans il y a | 1

| A accepté

Réponse apportée
Distance between two point with the same value
Assuming euclidean distance metric: n = randi(3, 10); %demo input vals = unique(n); %get unique values in n mdistances =...

presque 7 ans il y a | 1

| A accepté

Réponse apportée
Preprocessing using readtable()
Assuming you don't know which rows of the text file correspond to your start and end timestamps, what you want cannot be achieve...

presque 7 ans il y a | 1

| A accepté

Réponse apportée
Why does the for loop give wrong answer
For a start make sure that your numbers are all in the correct units. It looks like your density is in SI () but your pressure c...

presque 7 ans il y a | 0

| A accepté

Réponse apportée
Extracting lower triangle excluding the main diagonal elements to a string
B = strjoin(arrayfun(@(row) strjoin(compose('%d', A(row, 1:row-1)), ' '), 2:size(A, 1), 'UniformOutput', false), '\n') is one w...

presque 7 ans il y a | 1

| A accepté

Réponse apportée
How I do evaluate a function handle in other function handle
Your y_p never changes in your function. It's always the original . Shouldn't y_p be reevaluated at each step? Your 0.0001 delt...

presque 7 ans il y a | 0

Réponse apportée
Compute two matrices with different sizes and different values
it seems to me that the simplest and most reliable solution is to interpolate both velocity matrices to the same grid. Of course...

presque 7 ans il y a | 0

| A accepté

Réponse apportée
Error using copyfile No matching files were found.
I'd replace idx = strfind(myfile(i).name,'_thumb'); if ~isempty(idx) %do nothing else by the simpler ...

presque 7 ans il y a | 0

| A accepté

Réponse apportée
Extract values from a matrix
mean(yourmatrix(yourmatrix >= 3)) %mean of all values greater than or equal to 3

presque 7 ans il y a | 1

| A accepté

Réponse apportée
Create two fprintf in two diferent lines
You seem to be aware that '\n' is a newline so why don't you use it? fprintf('\n B1 \t B2 \t B3\t B4 \t B5\n'); %\n added a...

presque 7 ans il y a | 1

| A accepté

Réponse apportée
how to create an error message when invalid data is input and then prompt to re-enter the data
Typical pattern for this is: value = someinvalidvalue; while valueisinvalid value = input('Enter value'); end Note ...

presque 7 ans il y a | 0

Réponse apportée
Help with Simple OOP Program
As Thomas said, the kind of class you're developing would works better as a handle class. Note that if you derive from handle y...

presque 7 ans il y a | 0

| A accepté

Charger plus