Answered
Creating a graph of |sin(x)|
fun = @(x)abs(sin(x)); fplot(fun)

3 years ago | 0

| accepted

Answered
How to make random voids with for loop?
Why not just use a loop, something like this (aircode): % ... other model settings S = "e" + (1:10); for k = 1:numel(S) ...

3 years ago | 0

| accepted

Answered
Problem with writing datestr converted date time to a text file alongside other numeric variables
Have a look at this line: meteo = [DateTime(i,:) DOY(i,:) Ta_1_1_1(i,:)-273.15 TA_1_2_1(i,:)-273.15 Ts_1_1_1(i,:)-273.15 Ts_2_1...

3 years ago | 0

| accepted

Answered
Find data after 'matched' regular expresion in a file
The file you uploaded is encoded as UTF-16 LE with a BOM: https://en.wikipedia.org/wiki/UTF-16 https://en.wikipedia.org/wiki/B...

3 years ago | 0

| accepted

Answered
How to iterate over a char array and store them into a separate array?
"I want to be able create an array for each of these data structs ..." The simple approach is to use the structure array which ...

3 years ago | 0

Answered
Please help, I keep getting this error... Error using plot Not enough input arguments.
Rather than fiddling around with text and tickmarks, let MATLAB do it for you: V = [33.677;76.714;69.677;64.800;49.871;59.533;4...

3 years ago | 0

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

Load more