Community Profile

# Stephen23

Aktiv seit 2014

Suspensa Vix Via Fit

#### Statistiken

All

Abzeichen anzeigen

#### Content Feed

Anzeigen nach

Beantwortet
Building an array of strings that might be empty
"What am I missing?" The differences between strings and characters. Do not mix up string arrays with character vectors (which ...

ein Tag vor | 0

Beantwortet
Find a value using an index obtained from a different matrix with same dimensions

2 Tage vor | 0

Beantwortet
Using a menu to generate variables for larger code
For the 1st dialog box: V = str2double(answer); maxvel = V(1); dragco = V(2); width = V(3); mass = V(4); accdur = V(5);...

4 Tage vor | 0

| akzeptiert

Beantwortet
3D indices for particular values in a 3D array
Use IND2SUB: X = randi(9,4,3,2) [R,C,P] = ind2sub(size(X),find(X==8))

4 Tage vor | 0

| akzeptiert

Beantwortet
how assign cellarray to field Struct
"thank..but it's possible to avoid loop?" Of course (depending on the sizes and classes of APP, SIS, etc): app.Sis = struct('b...

4 Tage vor | 0

| akzeptiert

Beantwortet
Generate Array of Random Values
D = sort(randi([-9,9],7,2),2) V = rand(7,13); V = V.*diff(D,1,2)+D(:,1)

6 Tage vor | 0

Beantwortet
Hi, I want to speed up my script with double loop.
X = permute(A,[3,2,1]) + permute(B,[2,3,1]) The data arrangement in memory is not optimal for that operation. Use BSXFUN for ve...

7 Tage vor | 1

| akzeptiert

Beantwortet
How to replace exact char in a cell array from another reference cell array
This is difficult because 'x1' is also a substring of 'x10'. But making a few assumptions it might be possible: A = {'x1', 'x10...

7 Tage vor | 1

| akzeptiert

Beantwortet
Merge two matrices taking non-Null values
A = [8,8,8,8,NaN;32,32,25,31,NaN;56,56,43,53,NaN;81,80,60,76,NaN;105,103,78,99,NaN;129,127,95,122,NaN]; B = [8,NaN,8,8,8;32,NaN...

8 Tage vor | 1

Beantwortet
Dynamically Make a Variable Name
This is MATLAB so the best solution is to use indexing, just as the MATLAB documentation shows: https://www.mathworks.com/help/...

9 Tage vor | 1

Beantwortet
How to call a function name from function names saved in an array?
prev_output = [1,0,0]; fcs = sprintf('func%s',sprintf('%d', prev_output)); Either use FEVAL: output = feval(fcs,inputs); or ...

11 Tage vor | 0

| akzeptiert

Beantwortet
How to use Unicode numeric values in regexprep?
inp = 'Häagen-Dasz'; baz = @(v)char(v(1)); % only need the first decomposed character. out = arrayfun(@(c)baz(py.unicodedata.n...

15 Tage vor | 1

Beantwortet
Cutting (dividing) a matrix into a specific number of rows.
A = [11,12,13;21,22,23;31,32,33;41,42,43;51,52,53;61,62,63;71,72,73;81,82,83]; B = reshape(permute(reshape(A,[],2,3),[1,3,2]),[...

16 Tage vor | 2

Beantwortet
Why does MATLAB not finding a element from my matrix?
Testing for exact equivalence of binary floating point numbers should be avoided. Compare the values, are they actually the sam...

16 Tage vor | 1

Beantwortet
Question: Structure Array Generation and Dimensions Manipulation
Simple solution: new = [newpop(:);pop(:)] However if you want to your code to be more robust, then you need to preallocate NEW...

16 Tage vor | 0

| akzeptiert

Beantwortet
Printing all outputs of the function that has been solved via ode45
This questions gets asked regularly on this forum: users often imagine that there must be some easy way to get some values out o...

17 Tage vor | 1

| akzeptiert

Beantwortet
Index exceeds the number of array elements error when using fsolve
Your x0 is a two-element vector, so you told FSOLVE to call the function handle with a two-element vector. But then inside the f...

17 Tage vor | 0

| akzeptiert

Beantwortet
How do I plot a tent-map?
"How do I plot a tent-map?" Following the basic definition of tent map: https://en.wikipedia.org/wiki/Tent_map X = 0:0.01:1; ...

17 Tage vor | 1

| akzeptiert

Beantwortet
Impossible to set VariableTypes as 'double' for complete array and readtable function

18 Tage vor | 1

| akzeptiert

Beantwortet
Replacing numerical values in table with string
This is MATLAB, so forget about using a loop like that. Either replace the entire column at once or use e.g.: https://www.mathw...

21 Tage vor | 1

Beantwortet
Sorting files in struct according to time in filename

22 Tage vor | 0

Beantwortet
How to extract data from a file, and form a column vector?
Note that copy-and-pasting blocks of code like that... is not a generalized approach to writing code. Best avoided. Rather than...

25 Tage vor | 1

Beantwortet
Generate list of frequencies evenly spaced in logarithmic plot
X = logspace(log10(0.2),log10(628),8) Y = sqrt(X); semilogx(X,Y,'-*')

25 Tage vor | 1

| akzeptiert

Beantwortet
Extracting a double array from within a struct
"So in the end I will have an 18x297 array." Because there are a different number of columns in each matrix you will need to EI...

25 Tage vor | 0

| akzeptiert

Beantwortet
How can I get arguments in my MATLAB batch script to use a series of files with different character strings?
S = dir('/location/*/physio/*_PULS.log'); for k = 1:numel(S) F = fullfile(S(k).folder,S(k).name); T = readtable(F); %...

25 Tage vor | 0

| akzeptiert

Beantwortet
raising an element of a vector to a power gives complex number, but it should be real number
"Oh okay I guess I got it..." No guessing is required, this is explained by the rules of operator precedence: https://www.math...

27 Tage vor | 2

Beantwortet
How to import text data with different column lengths without having NaN
Keeping the corresponding pairs of columns together: T = readtable('test.txt', 'Delimiter',',') for k = width(T):-2:1 T =...

28 Tage vor | 0

Beantwortet
Matrixwise subtraction yields vector - how to reshape to original logical matrix?
A = rand(3); B = rand(3); X = A>=0.5; [~,C] = find(X); M = accumarray(C,A(X)-B(X),[],@mean).'

28 Tage vor | 0

| akzeptiert

Beantwortet
Observing Error while reading .csv files
Your code is fragile and complex. You should aim to simplify it and make it more generalised: avoid having lots of hard-coded t...

28 Tage vor | 1

Beantwortet
Too many input arguments error when cell2mat and mean functions are used
V = [23;27;26;17;7]; N = numel(V); C = nan(N,2); for k = 1:N M = vertcat(iniclu{k,1:V(k)}); % comma-separated list ...

etwa ein Monat vor | 1

| akzeptiert