# Stephen

Suspensa Vix Via Fit

**Statistics**

RANK**5**

of 242,765

REPUTATION**27,925**

CONTRIBUTIONS

**3** Questions

**7,419** Answers

ANSWER ACCEPTANCE **
100.0%
**

VOTES RECEIVED**4,539**

RANK**148** of 16,979

REPUTATION**7,838**

AVERAGE RATING**4.90**

CONTRIBUTIONS**22** Files

DOWNLOADS **699**

ALL TIME DOWNLOADS**62573**

CONTRIBUTIONS**0 Posts**

CONTRIBUTIONS**0** Public Channels

AVERAGE RATING

CONTRIBUTIONS**0** Highlights

AVERAGE NO. OF LIKES

**Content Feed**

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...

23 hours ago | 0

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...

1 day ago | 1

| accepted

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 ...

3 days ago | 0

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...

6 days ago | 1

| accepted

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...

7 days ago | 1

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...

7 days ago | 0

| accepted

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...

7 days ago | 1

| accepted

Use a structure with fields in a loop - Outputs & indexing ??

Where S is your structure: F = @(a)a.Sig(1); V = arrayfun(F,S)

8 days ago | 0

| accepted

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...

15 days ago | 0

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...

16 days ago | 0

| accepted

How to make the variable pace, a data type double

T = [0,33,3]; % the atheletes goal time [H,M,S] D = 10; % km P = required_pace1(T,D) class(P) P = required_pace2(T,D) % Usi...

17 days ago | 0

| accepted

Error using length, Too many input arguments.

if length(Obj.MatFile{cellnumber}{j}.(ExtractField))==2 But note that you do not need to check the length: taking the mean of o...

18 days ago | 1

Save output of a for loop in a vector

str = 'hello world. eat lots of bananas.'; target = zeros(150,1); for k = 4:numel(str) target(k) = isequal(str(k), str(k...

18 days ago | 0

Creating a new matrix and insert certain values into that matrix

I suspect that you are asking about SUB2IND: R = [1,3,3,2,2,3,3,4,3]; C = [1,1,1,3,4,1,2,1,4]; V = [2,2,2,4,2,3,3,2,1]; M = ...

20 days ago | 0

| accepted

Strings to variable names

Mixing up unrelated topics has made you think that this is much more complex than it really is. Look at your own code that you ...

23 days ago | 1

Random Number from a given vector of numbers

V = [-1,23,99,111,1024]; N = 3; A = V(randi(numel(V),1,N)) % with repetition B = V(randperm(numel(V),N)) % no repetition

23 days ago | 1

| accepted

How do I reformat a set of differently formatted dates in to one consistent format?

There is no tool which will correctly interpret the mutually-exclusive date formats used around the world: https://en.wikipedia...

25 days ago | 0

| accepted

Rewriting code without loops

Fake data: dev = rand(101,1); GradW = rand(4,101); HessW = rand(4,4,101); Your code: A = zeros(4,4,101); for i=1:101 ...

25 days ago | 0

| accepted

How to zero mean a 3-D array

The simple MATLAB approach: S = load('matlab.mat') A = S.A A = A - mean(A,2:3)

25 days ago | 0

| accepted

Won't show me my variable?

"What can I change to fix it?" Use logical indexing, e.g.: I = 0.5 * Ms; X = Ms>=3.5; I(X) = 21.29 * Ms(X) - 69.4; X = Ms>=...

25 days ago | 0

| accepted

Extract specific field names and associated data from a structure

Rather than using an IF it would be simpler to specify an appropriate filename for DIR: P = 'myfile'; S = dir(fullfile(P,'*bf_...

26 days ago | 0

| accepted

How can I extract the same variable from multiple files & concatenate them efficiently?

"I just can't seem to figure out how to efficiently extract a u and v vector from each file within the loop using my function be...

26 days ago | 0

Replace empty string with NaN in a cell

A = {"20","25","25",[],"20",[],"25","25","25","30"} A(cellfun(@isempty,A)) = {"NaN"} Using one string array is likely much bet...

27 days ago | 0

| accepted

copying specific elements of an array to another.

Forget about loops, the simple and efficient MATLAB approach is to use logical indexing: g = y(y>0.001)

28 days ago | 1

| accepted

how to shift rows to right and left of matrix ?

M = [1,2,3;4,5,6;7,8,9] A = [3,2,1]; B = [2,5,2]; c = [4,1,3]; for k = 1:size(M,1) if A(k)<B(k) %shift row to right wit...

28 days ago | 0

| accepted

How to create a pivot table from this table, Part 2

customer = {'Customer 1';'Customer 2';'Customer 3';'Customer 4'}; location = {'NY';'LA';'Austin';'LA'}; gender = {'male';'fe...

28 days ago | 0

| accepted

Doubt regarding max(A,B).

"Why is max(A,B) as [10 6 5]?" Because that syntax provides an element-wise comparison of the two input arrays, taking the maxi...

29 days ago | 3

changing the existing variables on the for loop

abc = [1,3,5,7]; k = abc; r = abc; for ii = 1:5 [r,k] = deal(k+3,r+5) end

29 days ago | 0

| accepted

how to use for loop for iterations in matrices?

"how to use for loop for iterations in matrices?" Do NOT number the variable names, unless you want to force yourself into writ...

30 days ago | 0

| accepted

Assigning an arbitrary number to an array

x = [2.32, 4.23, 1.92, 3.24, 2.13]; points = [3, 1, 2]; first_answer = x(points); [second_answer,idx] = min(first_answer); t...

30 days ago | 0

| accepted