Community Profile

photo

Stephen


Active since 2014

Suspensa Vix Via Fit

Statistics

All
  • Grand Master
  • Personal Best Downloads Level 4
  • Editor's Pick
  • First Review
  • 5-Star Galaxy Level 5
  • GitHub Submissions Level 3
  • First Submission
  • 36 Month Streak
  • Thankful Level 4
  • Revival Level 2
  • Knowledgeable Level 4
  • First Answer

View badges

Content Feed

View by

Answered
Split a cell array of character vectors at multiple-number delimiter
Rather than telling us what you currently get, it is probably more useful if you tell us what you want. I made some guesses abo...

en dag ago | 0

Answered
Reading mixed format data containing both text and numbers from a '.txt' file in matlab
fpt = '.'; % absolute or relative path to where the file is saved. fnm = fullfile(fpt,'text.txt'); % Count the header lines: ...

en dag ago | 0

Answered
Determining Order of flattening an array using colons
"If we use A(:,:) we expect an array with dimensions (X*Y, Z), with the i,j element pointing at (i mod X, i div Y, j) element o...

2 dagar ago | 1

| accepted

Answered
Saving file at different directory
You need to use FULLFILE to include the path in the filename, e.g.: [F,P] = uiputfile('FileNAME.txt'); fnm = fullfile(P,F); % ...

3 dagar ago | 1

| accepted

Answered
MATLAB plot is blank?
You are using matrix division where you should be using array division: https://www.mathworks.com/help/matlab/matlab_prog/array...

4 dagar ago | 0

| accepted

Answered
Get row number with certain data in it
"I tried the "find"-function but it didnt bring me to a useful result." It works for me: % Fake data: M = randi(9,7,2); M(5,...

4 dagar ago | 0

Answered
Add '_max' to odd variable names and '_min' to even ones.
T = array2table(rand(5,8),'VariableNames',{'Var1','t','Var3','ang_azi','Var5','vel_azi','Var7','acc_azi'}) T.Properties.Variabl...

4 dagar ago | 0

| accepted

Answered
How to I add zeroes onto a matrix?
Where V is your vector: V(end+1:52500) = 0

4 dagar ago | 1

Answered
I just need to get the numbers from this vector. The result must be a double. I need fast and clean code, as this operation is performed over and over again in my code.
Fastest: C = {'G07','G23','G04','G08','G20','G13','G30'}; V = sscanf(sprintf('%s',C{:}),'G%f')

4 dagar ago | 0

Answered
How do you capitalize the first and the third letter of each word in a sentence?
T = 'my pet is hungry'; U = regexprep(T,'(?<=\<(\w{2})?)(\w)','${upper($1)}') Of course because this is clearly homework you w...

4 dagar ago | 0

Answered
I need a function to identify if a number is part of a vector or matrix.
Where M is your matrix and N is your scalar number: any(N==M(:))

4 dagar ago | 1

| accepted

Answered
change the first digits when ends with 5959
Rather than messing around with strings you should probably just work with duration objects or numeric arrays. S = ["000000";"0...

5 dagar ago | 0

| accepted

Answered
How to merge two tables, keeping independent variable (x) the same but summing the dependent variable (y)
Simpler: T1 = readtable('Confoss_landings.xls', 'VariableNamingRule','preserve') T2 = readtable('Mainefoss_landings.xls', 'Var...

5 dagar ago | 0

Answered
Interpolate/Resample to a specific decimal point
Assuming no adjacent duplicate values: S = 1; V = [1,3,4,7,6,3,6]; X = cumsum([1,abs(diff(V))]); Z = interp1(X,V,1:S:X(end))...

5 dagar ago | 0

| accepted

Answered
How to combine 2 tables with different variables into 1 table?
The actual MATLAB solution just takes one simple line of code: SysTime = [1;2;3;4;5]; EDF = [10;20;30;40;50]; T1 = table(SysT...

5 dagar ago | 2

Answered
How to properly format a data table with fprintf?
A = [1,2,3,4,5]; fprintf('Numbers%s\n',sprintf(' %1.2f',A))

5 dagar ago | 0

Answered
Why the results of the matrix X' dont show?
Use https://www.mathworks.com/help/matlab/ref/mldivide.html A = [0,2,-1,0;0,0,1,-1;1,-1,0,0;-1,0,0,1]; B = [100;-500;300;100];...

5 dagar ago | 1

| accepted

Answered
Create Multiple Arrays While Looping Through One Single Array
By far the simplest and most efficient solution is to use one matrix: V = 1:81 M = reshape(V,9,9).' You can trivially access ...

6 dagar ago | 1

| accepted

Answered
how to add elements to an array in a for loop
The MATLAB approach is to use logical indexing, not a loop: V = [2,4,5,6,3]; N = sum(V(V>=5))

7 dagar ago | 0

Answered
I am unable to display my answers on command window
https://www.mathworks.com/help/matlab/ref/display.html a = [3 6 1 9; 6 5 3 7; 7 3 2 6]; display(a)

7 dagar ago | 0

Answered
Convert MAT file to v7.3
You can load and save the individual (or any selected) variables using the structure approach too. Lets try it: A = 1:3; B = 4...

8 dagar ago | 0

Answered
linspace not working on MATLAB Coder
In MATLAB it is usually better to loop over indices. Perhaps this would work: V = linspace(-r_max*Tc_usbl,r_max*Tc_usbl,decisio...

8 dagar ago | 1

| accepted

Answered
Normalize unit vector to single didgit integers
fun = @(V) round(V./10.^floor(log10(abs(V)))); fun([0.4,-0.4,0.8]) fun([0.123,0.123,0.5]) Note that this scales each element ...

10 dagar ago | 0

Answered
How can I run this script and only create folders with files in it without having an additional file outside the folder?
Get rid of the FOPEN and FCLOSE, they are completely unrelated to WRITEMATRIX: start = tic; % input n and m n = input('\n How...

13 dagar ago | 1

| accepted

Answered
Why does .m4a audio file (imported via audioread) get stored in workspace with two data series/data columns instead of just one?
Clearly your audio file has two channels. The MATLAB documentation states that the first output is "... returned as an m-by-n ma...

15 dagar ago | 1

Answered
random selection from 5 different vectors
C = {[1;2;3;2],[4;5],[7;8;9],[0;1;2],linspace(0,1,101)}; V = {1,1,1,1,2}; F = @(v,n)v(randi(numel(v),1,n)); Z = cell2mat(cell...

15 dagar ago | 0

| accepted

Answered
Plotting numeric data vs time (from text file)
"I am trying to import some numeric data from a text file and then plot it in MATLAB." T = readmatrix('time.txt'); M = readmat...

15 dagar ago | 1

| accepted

Answered
Use a structure with fields in a loop - Outputs & indexing ??
Where S is your structure: F = @(a)a.Sig(1); V = arrayfun(F,S)

16 dagar ago | 0

| accepted

Answered
How to load multiple .mat files containing timetables into the workspace and concatenate them vertically
"Do I have to rename the structs..." No, you do not need to. But in future when designing data you should keep the structure n...

22 dagar ago | 0

Answered
Please help i seem to be failing to understand what the following errors mean and how to correct for them.
I suspect that something like this is what you are trying to do (I fixed many small bugs): g = 9.8; %gravit...

23 dagar ago | 0

| accepted

Load more