Answered
Using a variable calculated in a function in the workspace
"I thought doing it this way the variable "jobname" is automatically returned to the workspace after the function is done." Nop...

5 years ago | 0

| accepted

Answered
Selective columns from multiple text folders
Here is one simple and efficient approach (untested, but should get you started): P = 'D:\work\1ST EXP\4.2'; V = 0:399; N = n...

5 years ago | 1

| accepted

Answered
Error using function load
load(matfiles(i).) % ^^ You forgot to write the fieldname. Note that you should specify the file extension and f...

5 years ago | 1

| accepted

Answered
How to bold or italicize any sentence or text using fprintf in matlab?
Pure text files do not contain any formatting information: https://www.mathworks.com/matlabcentral/answers/178646-how-to-read-t...

5 years ago | 0

Answered
Coverting specific string containing date to datetime
C = {... '2012_Q4' '2013_Q1' '2013_Q2' '2013_Q3' '2013_Q4' '2014_Q1' '2014_Q2' '2014_Q3' '2014_Q4'}; T = datetime(C, '...

5 years ago | 0

| accepted

Answered
Slow for loop string comparison
I assume that app.ttable.Time is actually a datetime array. In that case, your loop very inefficiently converts each datetime ...

5 years ago | 0

| accepted

Answered
Why is 10^(log10(x)) not x?
"Has anybody an explanation?" The simple explanation is: log10(a) is not exactly representable using a binary floating point nu...

5 years ago | 1

| accepted

Answered
How to remove the unwanted zero at the end in the floating point variable?
"How to remove the unwanted zero at the end in the floating point variable?" Trailing zeros are just an artifact of displaying ...

5 years ago | 0

Answered
Looping to create nested structure?
"...without manually creating a new structure for each time point." Creating individual structures by hand should definitely be...

5 years ago | 0

| accepted

Answered
delete files in folder with different endings
K = [".odb", ".txt", ".py", ".m"]; D = pwd; S = dir(fullfile(D,'*.*')); S = S(~[S.isdir]); % files only for k = 1:numel(S) ...

5 years ago | 0

| accepted

Answered
fprintf is outputting the wrong number, what's wrong with my code?
"what am i doing wrong?" You are printing a character code, not the value of a numeric variable. Replace this: fprintf('the sh...

5 years ago | 1

| accepted

Answered
How could I match data from two files?
T1 = readtable('FILE1.txt', 'ReadVariableNames',false) T2 = readtable('FILE2.txt', 'ReadVariableNames',false) Tout = join(T1,T...

5 years ago | 0

| accepted

Answered
In some specific case, preallocation is slower than doing nothing.
"What did I wrong?" Your timing comparison is 99% meaningless. Your are comparing the times of 100 loop iterations (the i loop...

5 years ago | 1

| accepted

Answered
creating year, month, day in month, hours in a day and minutes in that hour MATRIX for any year (e.g 2016)
T1 = datetime(2016,1,1,0,0,0); T2 = datetime(2017,1,1,0,0,0)-minutes(0.5); V = (T1:minutes(1):T2).'; M = [V.Year,V.Month,V.Da...

5 years ago | 0

| accepted

Answered
why the + sign get invalid use of operator?
Note the difference: 1 + 2 % what MATLAB actually supports 1 .+ 2 % what you used There is no separate array version of the ...

5 years ago | 0

Answered
Add to a vector from loop
The MATLAB way: N = 1:1000000; X = abs(cos(N)) < 1./N; T = nnz(X) % total Z = N(X) % those which pass your condition

5 years ago | 0

| accepted

Answered
Creating a table with matrices and arrays as elements
Lets have a look at the data: S = load('visualOdometryGroundTruth.mat') T = S.groundTruthPoses The curly braces in the 2nd an...

5 years ago | 1

| accepted

Answered
How can I interpolate matrix?
M = [0,0,0,0,31.2117;0,0,0,0,0;0,0,0,0,0;0,0,0,0,0;33.4177,0,33.0571,0,32.2147] [Xi,Yi] = find(M); [Xo,Yo] = ndgrid(1:size(M,1...

5 years ago | 2

| accepted

Answered
How to shift a vector using 'for' loop
Store all of the vectors in one cell array (which they should be anyway): C = {V1, V2, V3, V4 ...}; then all you need is this ...

5 years ago | 0

| accepted

Answered
How do you save values from a for-loop in a vector?
With MATLAB it is almost always better to loop over an index than to loop over data: ml = 100:50:1000; n = numel(ml); z = nan...

5 years ago | 0

| accepted

Answered
join 2 strings together to 1
Your example data (you need to learn the difference between string arrays and character arrays): A = "Biegung_35_"; % scalar st...

5 years ago | 0

| accepted

Answered
How to create a table from a string array as header and a numerical matrix as data?
"How can I create a table with this header and matrix as data and write it to excel with writetable?" M = rand(101,37); % fake ...

5 years ago | 0

| accepted

Answered
Plotting multiple lines on one graph
t = [0,0.000225,0.00045,0.00113]; z = 0:0.001:1; z = z(:); C = (sin(3*pi*z).*exp(-50*(3*pi)^2.*t))-(sin(9*pi*z).*exp(-50*(9*p...

5 years ago | 0

| accepted

Answered
Improve speed reading in a .dat file
Some version of this is probably the fastest you can get: [fid,msg] = fopen('example.txt','rt'); assert(fid>=3,msg) for k = 1...

5 years ago | 0

Answered
Make specific columns of a matrix zero.
A = [1,2,3,4,5,6,7,8,9; 5,8,6,44,8,6,8,7,3; 9,8,7,6,5,4,3,2,1]; b = [1,4,5,9]; out = zeros(size(A)); out(:,b) = A(:,b)

5 years ago | 1

| accepted

Answered
Multiply two terms at a set distance apart from each other in an array
The MATLAB approach: v = arr(1:end-23) .* arr(24:end);

5 years ago | 2

Answered
Save structure in Excel
F = fieldnames(dataset); N = 'myfile.xlsx'; for k = 1:numel(F) T = dataset.(F{k}); writetable(T, N, 'Sheet',F{k}) e...

5 years ago | 0

| accepted

Answered
How to find the following pattern in my Char variable in the workspace?
Assuming no nested curly braces: str = '"costOfRevenue":{"raw":4751000000,"fmt":"4,75B","longFmt":"4.751.000.000"},"totalOtherI...

5 years ago | 1

| accepted

Answered
Dir function with no file extension
Try specifying the fixed part of the filename: S = dir('Data*') and/or removing folder from the output: S = dir('*'); S = S(...

5 years ago | 0

| accepted

Answered
Why can't Matlab find functions from a project folder within another project folder?
Folders starting with "+" are package folders: https://www.mathworks.com/help/matlab/matlab_oop/scoping-classes-with-packages.h...

5 years ago | 0

| accepted

Load more