Answered
Concatenate cells of a cell array rows into single cell
Use NUM2CELL: C = [repmat({'a'},3,1), repmat({'b'},3,1), repmat({'c'},3,1), repmat({'d'},3,1)] C2 = num2cell(C,2).'

3 years ago | 0

| accepted

Answered
Save all values of a calculation through a loop in a file
"How can I save all the results for each calculation in the mat file?" The standard, efficient, simple approach is to store the...

3 years ago | 1

| accepted

Answered
How to combine the data from multiple netcdf files and make it one .mat file?
Do not expand/concatenate the data inside the loop! A more robust & efficient approach: concatenate once after the loop: S = d...

3 years ago | 1

Answered
Execution of script as a function is not supported
The problem is that you named the script mix_2d_lp_fonc Then when the script gets to this line: fcn_handles = mix_2d_lp_fonc(p...

3 years ago | 0

| accepted

Answered
Read multiple .mat files and process them
"As you said in my case the variable's name changes on each iteration of the outer loop." With changing variable names you will...

3 years ago | 1

| accepted

Answered
Looping through sets of names for a match and selecting variable with this name
replace if xx == ID with if strcmp(ID,accvectors_name{xx}) "There is certainly something wrong because instead of a value be...

3 years ago | 1

Answered
how to extract table data in structure using multi variables in its path
The simple solution is to always LOAD into an output variable, which itself is a scalar structure. For example: F = 'C:\Users\E...

3 years ago | 1

| accepted

Answered
For loop to store one matrix from multiple files to a structure
P = 'C:\Users\Document\Data'; S = dir(fullfile(P,'*.mat')); for k = 1:numel(S) F = fullfile(S(k).folder,S(k).name); ...

3 years ago | 1

Answered
Creating cell array from multiple structs that has struct components directly accessible?
Your code would be simpler and more robust if you had given every structure exactly the same name. Rather than forcing meta-data...

3 years ago | 0

Answered
When mapping smaller arrays to a bigger array, how do I have overlapping elements be added?
A = ones(4,4); B = ones(4,4); C = blkdiag(A,0,0)+blkdiag(0,0,B)

3 years ago | 1

| accepted

Answered
How to read a specific value next to a text in a text file?
raw = strtrim(readlines('Txt.txt')); idx = strcmp(raw,'')|strcmpi(raw,'Zone,'); raw(idx) = []; % split the values and keys: ...

3 years ago | 0

Answered
""Unrecognized variable name 'Time'" I am getting this type of error during ploting , how I can fix this?
The files are formatted slightly differently, as these screenshots show: The READTABLE() documentation gives some options t...

3 years ago | 1

Answered
ind2sub with arbitrary martix
"In the example below: how to set the three output arguments [I1 I2 I3] "automatically" ?" You use a comma-separated list: htt...

3 years ago | 2

| accepted

Answered
Truncate strings to maximum length
str = ["", "ab", "1234", "cdefgh"]; out = regexprep(str,'^(.{1,4}).*?$','$1') % LEFT out = regexprep(str,'^.*?(.{1,4})$','$1')...

3 years ago | 1

Answered
Converting Table Output from 1 Format to Another
T = cell2table({'28/0.85','XHHP15AA001';'43/0.85','XHHP17AA001';'24/1.35','XHHP18AA001';'34/1.35','XHHP19AA001'},... 'Varia...

3 years ago | 0

Answered
How can I make an array using for loop?
TimeSeries = vertcat(Time{:,1}); https://www.mathworks.com/help/matlab/matlab_prog/comma-separated-lists.html https://www.math...

3 years ago | 1

Answered
Retrieving numbers present within an array by knowing the coordinates
The simple and efficient MATLAB approach is to use SUB2IND: SI = load('image_DEF_numero_pixel.mat') im = SI.image_DEF_numero_p...

3 years ago | 0

| accepted

Answered
readtable fail to import .22p file
One simple approach is to call DETECTIMPORTOPTIONS() on a known good file**, and use those options for all of the other files. T...

3 years ago | 0

| accepted

Answered
Plotting a function with an array of x returns one y value
You won't get very far using MATLAB if you do not learn the difference between array and matrix operations: https://www.mathwor...

3 years ago | 0

Answered
Files are not loading into my program
"i dont really know what am i doing wrong..>" You are using LS() instead of DIR(). LS() is intented for a pretty display, not ...

3 years ago | 0

Answered
Creating file path names in a loop
lensFile = System.IO.Path.Combine(fileDir, [fname,'.zmx']); % ^ ^

3 years ago | 0

| accepted

Answered
convert cell array of mixed strings to cell array of numbers
ca = {' [1000 X X X X]', ' X', ' X', ' 1.234' } out = regexp(ca,'[^\s\[\]]+','match'); out = cellfun(@str2double,out,'uni',0)

3 years ago | 1

Answered
A compact way to horizontally concatenate rows of many cell arrays ?
a = {{[0,0,1,4,1];[9,9,0,0,0];[2,3,5,1,2]};{[1 0 7 4,0];[2,8,8,2,6];[1,9,8,1,1]};{[7,7,6,0,6];[9,0,9,1,2];[3,9,2,4,6]};{[3,3,3,2...

3 years ago | 1

| accepted

Answered
generate out put names and output number dynamically
Because you did not upload any data I will use an inbuilt dataset: S = load('fisheriris.mat'); X = S.meas(:,3:4); Now lets gr...

3 years ago | 0

| accepted

Answered
A compact way to sum the elements contained in two cell arrays (considering the case of empty cells as well)
a = {[0,0,0,0,0,0,0,36,43,48,42,49,51,64,55,57,86,69,53,37,35,37,31,0]; [21,0,0,0,0,0,0,31,64,53,50,81,55,72,76,93,108,81,8...

3 years ago | 1

| accepted

Answered
How can I access a nested struct data by indexing of the fields?
url = 'https://lotus.naturalproducts.net/api/search/simple?query='; sfx = 'LTS0120864'; raw = webread(strcat(url,sfx)) "Howev...

3 years ago | 1

| accepted

Answered
I just wrote a recursive function which create a structure nested by the fieldnames given by an array but it doesn't work
The simple MATLAB approach is to use SETFIELD() with a comma-separated list: C = {'f1','f2','f3'}; V = pi; S = struct(); S =...

3 years ago | 0

Answered
Error using vertcat and how to solve it?
f = @(t,x) [-x(4)-(0.424)+(1.6977)*exp(-1.35*10^20*(x(1)^2)); x(4)-(0.663)+(2.6540)*exp(-1.35*10^20*(x(2)^2)); -(2.994...

3 years ago | 0

| accepted

Answered
How to load multiple .mat files which are having subfile in .mat format using the loop?
Unfortunately the data in those MAT files is very badly designed, because each MAT file uses a changing prefix on the variable n...

3 years ago | 0

| accepted

Answered
Accessing and synchronizing timetables in cell array?
Do not use a loop for this! The simple MATLAB approach is to use a comma-separated list: https://www.mathworks.com/help/matlab/...

3 years ago | 1

| accepted

Load more