# Stephen

Suspensa Vix Via Fit

**Statistics**

RANK**5**

of 244,610

REPUTATION**28,207**

CONTRIBUTIONS

**3** Questions

**7,483** Answers

ANSWER ACCEPTANCE **
100.0%
**

VOTES RECEIVED**4,599**

RANK**142** of 17,084

REPUTATION**7,995**

AVERAGE RATING**4.90**

CONTRIBUTIONS**22** Files

DOWNLOADS **831**

ALL TIME DOWNLOADS**63613**

CONTRIBUTIONS**0 Posts**

CONTRIBUTIONS**0** Public Channels

AVERAGE RATING

CONTRIBUTIONS**0** Highlights

AVERAGE NO. OF LIKES

**Content Feed**

for loops and storing values

"what can i do to solve this?" Use indexing into a preallocated array: c = nan(46,4); % <--- preallocate! for h = 1:23 f...

12 hours ago | 1

I am getting error

You need to use array operations, not matrix operations (you missed this for multiplication): https://www.mathworks.com/help/ma...

12 hours ago | 0

Error with matrix "Error using vertcat" Dimensions of arrays being concatenated are not consistent.

The problems are on these lines: 0 0 0 0 -1 0 1 0 0 mp*AG4x-Fp4x(1,i) 0 0 0 0 0 -1 0 1 0 mp*AG4y-Fp4y(1,i) Because AG4x and A...

12 hours ago | 0

| accepted

How to normalize only one column of a matrix

normalize(X(:,2),'range',[0,1]) or simply rescale(X(:,2)) If you want to replace the data in the matrix then allocate the fun...

13 hours ago | 0

I need to write a code to import multiple csv files, changing delimiter and decimal standard...

Use READMATRIX and set the Delimiter and DecimalSeparator to values that suit your file.

13 hours ago | 0

| accepted

merging workspace from different .mat files

"I think the problem ive run into is my files contain the same variable names..." That is not a problem at all, actually that i...

14 hours ago | 0

| accepted

Why doesn't this function declaration work?

You are missing a closing parenthesis here: concentrations(n-i-1) = maxconc*(1/factor^(i-1); % ...

15 hours ago | 1

| accepted

Using sprintf to match the results of format

Introduced in R2021a: https://www.mathworks.com/help/matlab/ref/formatteddisplaytext.html format short str = strtrim(formatted...

15 hours ago | 0

How to code with for loop loops without using ndgrid?

As this is clearly homework, this should get you started: inp = {1:2, 3:4, 5:6}; [A,B,C] = ndgrid(inp{:}); A1=reshape(A,[],1)...

16 hours ago | 0

Expected Behavior for contains()?

Exactly as its documentation explains, CONTAINS returns a logical TRUE where pat (second input) is found anywhere within the str...

18 hours ago | 0

| accepted

How to perform operations on time matrices

a = [0,2.3450,3.4570;1,3.4670,4.8750;2,4.6350,5.8350] m = a(:,2:end)-mean(a(1,2:end)); [~,x] = sort(m<0,1); for k = 1:size(m,...

3 days ago | 0

Operate by logical arrays element by element (error: Unable to perform assignment because the left and right sides have a different number of elements.)

a = [1,nan]; b = [8,9]; x = isnan(a); a(x) = b(x)

3 days ago | 0

| accepted

Finding consecutive zeros in an array. Not able to solve using diff command

a = [0,0,1,1,-1,0,0,0,1,1,1,-1,0,0,1,-1]; d = diff([false,a==0,false]); b = find(d>0); e = find(d<0); m = max(e-b)

4 days ago | 0

| accepted

Incorrect results from intersect when entering imaginary numbers

A = readmatrix('data1.txt') B = readmatrix('data2.txt') C = intersect(A,B,'rows')

5 days ago | 0

Trouble Reading Multiple .csv Files. "Intermediate dot '.' indexing produced a comma-separated list..." Error.

DataID(i).AxialStrain = DataID(i).RawData(1:ending,1); % ^^^ you need this index every time you ref...

6 days ago | 1

| accepted

loop on handles on GUI

fnm = sprintf('checkbox%d',i); handles.(fnm)

6 days ago | 1

| accepted

how to read files with different name using fid

fnm = sprintf('pfoil_1_var_1_%d.raw',i); fid = fopen(fnm,'r');

6 days ago | 1

| accepted

Sorting Nested Structures based on Name

As far as I can tell, your actual goal is to sort the elements of all structures based on the content of their NAME field. Assu...

7 days ago | 0

| accepted

Find the index of an interval of values in cell array

index = cellfun(@(x) 500<x & x<956, SS, 'uniform', false);

7 days ago | 0

Replace comma with dot after fopen

fnm = 'trial_file.txt'; opt = detectImportOptions(fnm, 'VariableNamesLine',9, 'VariableUnitsLine',10, 'DecimalSeparator',',', '...

8 days ago | 1

How to split array into sub arrays?

"I have a feeling that creating individual variables is not most efficient method..." Creating lots of individual variables wou...

10 days ago | 0

| accepted

Writing pressed key to variable

I suspect that you are getting synchronous code (e.g. the evaluation of a script or function) mixed up with asynchronous code (e...

11 days ago | 0

Array don't store value?

Replace n = linspace(t01,t11,h); % Read its help to know why your useage is incorrect. with n = t01:h:t11;

11 days ago | 0

| accepted

How to create a vector inside a loop with data from a struct ?

T = {ECG.event.type}; % comma-separated list L = [ECG.event.latency]; % ditto xAB = strcmp(T(1:end-1),'A') & strcmp(T(2:end),'...

12 days ago | 0

| accepted

How to store data when a string condition of another column is met?

T = readtable('SED_FULL_NE.xlsx') [G,YEAR,STATE_ABBR] = findgroups(year(T.BEGIN_DATE),T.STATE_ABBR); COUNT = accumarray(G,ones...

13 days ago | 0

| accepted

find ( strcmp ( many_different_elements )

"But was wondering if there's a nicer way than to write 90 times in the find line" Of course: forget about repeated STRCMP call...

14 days ago | 0

Compare two Vectors and multiply equal entries

ID = 'ABCDEF'; val = 1:6; arr = 'AABBCDDDEFFE'; [X,Y] = ismember(arr,ID); out = val(Y(X))

15 days ago | 0

| accepted

Convert a cell array into arrays

Where C is your cell array: M = vertcat(C{:,4}) or M = cell2mat(C(:,4))

15 days ago | 1

| accepted

A function that counts the number of zeros in a vector

D = [1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0]; nnz(D==0)

16 days ago | 1

Get the position of the next in row and next in column in a matrix

A reasonably simple, efficient, robust approach: A = [1,0,-2,0,0;2,8,0,1,0;0,0,3,0,-2;0,-3,2,0,0;1,2,0,0,-4] [C,R] = find(A.')...

16 days ago | 1