Answered
How do I sort data in a table in ascending order given specific Series type in Column
Either data = sortrows(data,{'Series','Year'}) or data = sortrows(data,{'Year','Series'}) depending on what you expect the o...

5 years ago | 0

Answered
Row and Cloumn find in cell array
What you want is actually the cell index and the index of the cell content, not the "row and column" index as you wrote. f = {[...

5 years ago | 0

Answered
extracting numbers with decimal places from the body of text file and assigning to a variable
%str = fileread(..) % <- simpler way to import the file data. str = sprintf('%s\n','Header with text and comments','other text ...

5 years ago | 1

| accepted

Answered
Loop does not save intermediary steps
"Loop does not save intermediary steps" because nothing in your code makes any attempt to save them. Because each diagonal has ...

5 years ago | 0

| accepted

Answered
interpn vs griddata, not producing the same results when interpolation is only in 2 dimensions
Your code seems to have some bugs: the first and second dimensions should NOT be included in the indices for griddata (i.e. the...

5 years ago | 0

Answered
Creating dynamic variables using loops | Automatic Variables using loops
"How do I bypass this without creating variables using loops." Here is a simple solution using basic MATLAB operations, no bad ...

5 years ago | 2

Answered
How to extract valid and invalid values from 1 array into 2 new arrays?
The loop does nothing, get rid of it. Using find will not solve your problem. The actual problem is that your logic for either ...

5 years ago | 0

Answered
Creating a for loop that calls to a separate function script and collects outputs in vector
One simple approach: cnt = 0; Results = nan(n*n,7); % preallocate 10000x7 for ii = 1:n for jj = 1:n cnt = cnt+1...

5 years ago | 0

| accepted

Answered
Define new operations for a matrix
x = [0,1,2,0,1,0,3,1,0]; y = x.'; V = 0:3; % define value range of multiplication table M = [0,1,2,3;1,0,3,2;2,3,0,1;3,2,1,0]...

5 years ago | 0

| accepted

Answered
Is there a readfile() function in Matlab?
Perhaps they meant this third-party function: https://www.mathworks.com/matlabcentral/fileexchange/68780-readfile/ To get a co...

5 years ago | 0

| accepted

Answered
Continuous Loop operation with conditional statements in table and then calculation
No need to use a loop: T = [1317;1327;1342;1390;1391;1392;1393;1446;1453;1464;1491;1607;1608;1609]; D = diff([false;diff(T)==1...

5 years ago | 0

| accepted

Answered
Recoding unique numbers to another number
The simple and efficient MATLAB solution: X = [5,5,6,6,6,11,11]; [~,~,Z] = unique(X,'stable')

5 years ago | 0

| accepted

Answered
Two numbers that should be equal are not, fractional part showing different values after 17th fractional digit
"Why does this happen? What could have caused such imprecision during calculation?" Operations on binary floating point numbers...

5 years ago | 3

| accepted

Answered
How to change big fractions in small numbers in command windows
syms s S u=(4*s)-(3*sym(pi)); v=(s^2)+(sym(pi)^2); f(S)=u/v; ilaplace(f(S))

5 years ago | 1

Answered
How to create a categorical variable with a specified number of characters?
labels = [repmat('N',1883,1);repmat('A',332,1)]; or less robustly: labels( 1:1883,1) = 'N'; labels(1884:2215,1) = 'A'; % ...

5 years ago | 0

| accepted

Answered
Profiling of inefficient recursive Fibonacci series function
Perhaps something like this: [val,vec] = fibo(6) function [f,t] = fibo(n) if n <= 2 f = 1; t = f; ...

5 years ago | 1

| accepted

Answered
Adds one element in vector from another, by position in array
x = 1:100; % superfluous square brackets removed. y = x(3:end-1)+x(4:end) % the MATLAB way.

5 years ago | 0

| accepted

Answered
How to turn a string into a line of differential equation for ode45?
Ugh, do NOT use eval for this! If the string is actually a symbolic expression then use odeFunction as Walter Roberson stated. ...

5 years ago | 1

Answered
Comparing cell arrays and creation of subfolders
A much more robust approach using absolute filenames (rather than buggy and slow CD) and function syntax rather than outdated co...

5 years ago | 0

Answered
For loops for functions that create structure arrays.
Your indexing throws an error because beta_list has only one column but you are trying to access columns 2 to 61, which don't ex...

5 years ago | 0

Answered
How to create an N-ary array
N = 4; K = 3; C = cell(1,K); [C{:}] = ndgrid(1:N); M = reshape(cat(K+1,C{:}),[],K) How it works: https://www.mathworks.com...

5 years ago | 0

Answered
Hex 01A9 to 16-binary?
No loops, no padding, works correctly for any number of hex digits (not just 16 bits): H = '01A9'; B = reshape(dec2bin(sscanf(...

5 years ago | 1

Answered
How to modify a list of filenames in a specific way?
S = ["vul1_4_9.txt" "bat1_1_1.txt" "chy1_1_16.txt" "chy1_1_17.txt" "g6_1_18.txt" "stcv1_1_1.txt" "...

5 years ago | 0

| accepted

Answered
Import matrices with same name and dimensions from different Data
"What should i do ?" Load into an output variable, not directly into the workspace. Loading into an output variable will avoid...

5 years ago | 0

Answered
Summing Datenum resets after 24 hours
As Steven Lord wrote, serial date numbers are not the right tool for the task: amongst other things you will struggle against de...

5 years ago | 0

| accepted

Answered
How to import multiple .mot files?
S = dir(filePattern); for k = 1:numel(S) F = fullfile(S(k).folder, S(k).name); fprintf('Now reading %s\n', F); S...

5 years ago | 0

Answered
Saving an imported.txt file as .mat file in a for loop using the same original file name
[~,old] = fileparts(File_Struct(K).name); % remove file extension new = sprintf('%s.mat',old); % add .mat file e...

5 years ago | 0

| accepted

Answered
Sort rows of a table based on vector
The MATLAB approach: new_table = stim_sheet(a,:)

5 years ago | 0

Answered
Conditional loop to loop until result is an integer.
As it is currently implemented that algorithm will not work because it does not take into account the behavior of binary floatin...

5 years ago | 1

| accepted

Answered
How to load data from csv-files with "dot"-structured variable names and convert to struct/table?
Better than evil EVAL is to use more robust SETFIELD and a comma-separated list: str = 'in.sensors.temp.x'; val = pi; tmp = r...

5 years ago | 1

| accepted

Load more