Answered
Removing certain type of repeating cell
A direct, intuitive, and reasonably efficient approach is to simply check the existing cell array content: out = Conc(5) fun...

4 years ago | 0

| accepted

Answered
Read .txt file into a matrix and remove unwanted text
Simpler: str = fileread('N2_trace.txt'); tkn = regexp(str,'^(\d+)\.?\d*:[^:]+:\s+([^\n]+)','tokens','lineanchors'); tkn = ver...

4 years ago | 1

| accepted

Answered
How can I check if it is a string?
The simplest approach is to use ISNAN, because STR2DOUBLE will return NaN for any input that it cannot convert to numeric: if i...

4 years ago | 1

| accepted

Answered
Selecting a specific part in a string array
tmp = split(strg_cell(i,1)); x3(i,:) = tmp([1,end]); The MATLAB approach would be to use a simple FOR loop, rather than painfu...

4 years ago | 0

Answered
Using Textscan to read Sinex file rows with variable delimiters
This is a fixed-width file, especially e.g. the presence of space characters in the location names indicates this. The header un...

4 years ago | 0

| accepted

Answered
How to change a Data Series contained with Repeated NaNs to become other sequence of NaNs?
A = [NaN, NaN, NaN, 0, 0, NaN, NaN, 0, 0, 0, 0, 0, NaN, NaN, NaN, NaN, NaN] X = diff([isnan(A),false])<0; A(X) = 0

4 years ago | 1

| accepted

Answered
when using listdlg is it possible to use tex characters in the ListString?
With recent MATLAB versions and OSs you can just use σ: listdlg('ListString' , {'Von Mises Stress', 'σ_x' , 'σ_y'}) E.g. R2018...

4 years ago | 0

Answered
Removing element of array at random
a = 0; b = 1; rn = b*randn(200,1)+1; ix = randperm(200,10) % indices of elements to remove rn(ix) = []; % remove elements

4 years ago | 0

| accepted

Answered
How to place a value in a function
F_x is an array, not a function (in the MATLAB sense: https://www.mathworks.com/help/matlab/function-basics.html) To access ele...

4 years ago | 0

| accepted

Answered
How to get particular data from column of table in MATLAB
What you uploaded is not a CSV text file, it is an XLSX file with an incorrect file extension. I fixed the file extension for y...

4 years ago | 1

Answered
add value to cell array
if numel(label_text_output) label_text{end+1} = label_text_output end Or alternatively afterwards you could do this: lab...

4 years ago | 0

| accepted

Answered
"audioread" multiple audio files in a folder
You need to tell AUDIOREAD the filepath, otherwise it does not know where to find the files. P = 'C:\Users\KOH\Desktop\MATLABco...

4 years ago | 1

| accepted

Answered
If statement without loop
A = repmat(1:5,4,1) B = [3;2;1;5] C = A; C((1:5)>=B) = 0

4 years ago | 0

| accepted

Answered
date to string conversion
Ugh, do NOT use DATESTR. This is easier without using the old, imprecise, deprecated functions: aa = datetime('now','Format','d...

4 years ago | 1

| accepted

Answered
structure to a matrix
S = load('DD_hyde_iisc_0.3to6.3_15.mat') T = struct2table(S.DD_SlantSmoothTEC)

4 years ago | 1

| accepted

Answered
how to convert array of cells within array of cells in single cell array
A = {{[2,3,4]},{ [],[3,4],[3,8,13]},{[4,0]},{[9,4],[9,8,13],[],[9,14,19]}} B = [A{:}] https://www.mathworks.com/help/matlab/ma...

4 years ago | 0

Answered
Passing multiple Arrays to loop a Function and creating a 1 column array
Assuming that the function output is scalar: mmm = zeros(sz,1); for k = 1:sz mmm(k) = Function(HistoricalValue,A(k),C(k),...

4 years ago | 0

Answered
How do I cd inside a for loop to a bunch of folders containing a file with same name?
Do not change directory just to import/export data files. Use absolute/relative filepaths instead, it is more efficient and eas...

4 years ago | 1

| accepted

Answered
Import 3D matrix in .mat File
"Hi, I have a file 'data.mat' attached. The file contain a 3D matrix with 128x128x128 dimension." No, it does not. It actually ...

4 years ago | 0

| accepted

Answered
Load files with similar name
P = 'absolute or relative path to where the files are saved'; S = dir(fullfile(P,'user_*.csv')); for k = 1:numel(S) F = f...

4 years ago | 0

| accepted

Answered
Avoid using eval on loading struct from a file
"As using eval is not the optimal way, is there any other way to do this?" Always LOAD into an output variable (which is a scal...

4 years ago | 0

Answered
I'm newish to MATLAB and want to automate populating a matrix A rather than manually create...
TM = [0.1,0.1,0.1,0.1,0.1,0.2,0.3,0.4,0.6,0.8,1.0,1.0,1.0,1.0,1.0,0.8,0.6,0.4,0.2,0.1,0.0]; N = 4; M = toeplitz([TM(1),zeros(...

4 years ago | 0

| accepted

Answered
x=[1 2 3 4]y=[2 4 5 10]x1=[1,1.5,2.2,3.5,4] how to get previous matching value(from y) for x1 by refering x expected answer y1=[2 2 4 5 10] without forloop
x = [1,2,3,4]; y = [2,4,5,10]; x1 = [1,1.5,2.2,3.5,4]; %y1=[2,2,4,5,10]; y1 = interp1(x,y,x1,'previous')

4 years ago | 0

| accepted

Answered
read multiple channels of different amounts of data into single matrix
Assuming that all imported matrices have exactly the same number of columns in the same order: N = 10; C = cell(1,N) for ch =...

4 years ago | 0

| accepted

Answered
How to use strings to access a multi-level structure?
The variable name should not be dynamically accessed: https://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-varia...

4 years ago | 1

Answered
Corrupted Order of the Elements of struct.name After Using dir Function
For those filenames you can simply define the regular expression to include leading whitespace: C = {'100.jpg',' 99jpg'}; % che...

4 years ago | 0

Answered
Get data from each row as inputs to a function
N = numel(Strike); Volatility = cell(1,N); for k = 1:N Volatility{k} = impvbybjs(RateSpec,StockSpec,Settle,Maturity,Opt...

4 years ago | 0

Answered
Interpolation input grid is not a valid meshgrid
You mixed up the dimensions. This follows the explanation and examples in the INTERP2 documentation: omega = ((1/3.6)/0.0625)*[...

4 years ago | 0

| accepted

Answered
Read and process multiple sheets from Excel to Matlab
Untested, but this should get you started: P = 'absolute or relative path to where the files are saved'; F = 'filename.xlsx'; ...

4 years ago | 1

| accepted

Answered
Separating a CSV into multiple CSVs by an ID within the CSV, using that ID as the new filename
Most likely you only need one loop. Because you did not upload a sample file I had to create my own (attached): T = readtable('...

4 years ago | 1

| accepted

Load more