3,218 total contributions since 2014

Suspensa Vix Via Fit

Answered

How can I plot several graphs with slightly different name in a loop?

How MATLAB works is different to what you are attempting: you simply allocate values into the array using indexing, rather than ...

How can I plot several graphs with slightly different name in a loop?

How MATLAB works is different to what you are attempting: you simply allocate values into the array using indexing, rather than ...

2 hours ago | 0

Answered

Wanted: Examples on how to use "Dynamic Regular Expressions" to debug regular expressions

As far as I can tell there is no simple "regexp-debug" tool or method, but here are a few tips based on my experience writing my...

Wanted: Examples on how to use "Dynamic Regular Expressions" to debug regular expressions

As far as I can tell there is no simple "regexp-debug" tool or method, but here are a few tips based on my experience writing my...

3 hours ago | 2

Answered

Longest segment of successive numbers of a sequence

>> V = [1,2,7,8,3,9,4,7,2,5,7,8,9]; >> D = [0,find([diff(V)<0,true])]; >> [~,X] = max(diff(D)); >> V(D(X)+1:D(X+1)) ...

Longest segment of successive numbers of a sequence

>> V = [1,2,7,8,3,9,4,7,2,5,7,8,9]; >> D = [0,find([diff(V)<0,true])]; >> [~,X] = max(diff(D)); >> V(D(X)+1:D(X+1)) ...

24 hours ago | 0

| accepted

Question

TUTORIAL: Why Variables Should Not Be Named Dynamically (eval)

Beginners sometimes want to dynamically create or access variable names, the variables are often named something like these: ...

3 days ago | 16 answers | 11

Answered

Write a function nextinteger(v) which takes as input a vector v and as output returns the smallest positive integer which does not appear in v. For example, if the input is [1, 2, 3], the output would be 4. If the input is [4, 0, 1, -10], output =2

Currently your code only calculates the value 1+max(v), whereas you need to identify the _first_ integer that is not in |v|, som...

Write a function nextinteger(v) which takes as input a vector v and as output returns the smallest positive integer which does not appear in v. For example, if the input is [1, 2, 3], the output would be 4. If the input is [4, 0, 1, -10], output =2

Currently your code only calculates the value 1+max(v), whereas you need to identify the _first_ integer that is not in |v|, som...

3 days ago | 0

Answered

I want to build a structure that includes multiple matrices

A cell array would be simpler than a structure: >> C = num2cell(zeros(100,3),2); >> C{1} ans = 0 0 0 >> ...

I want to build a structure that includes multiple matrices

A cell array would be simpler than a structure: >> C = num2cell(zeros(100,3),2); >> C{1} ans = 0 0 0 >> ...

3 days ago | 0

Answered

cannot iterate over subdirectories from data structure

You need use <https://www.mathworks.com/help/matlab/matlab_prog/access-data-in-a-cell-array.html cell array indexing> with a cel...

cannot iterate over subdirectories from data structure

You need use <https://www.mathworks.com/help/matlab/matlab_prog/access-data-in-a-cell-array.html cell array indexing> with a cel...

14 days ago | 1

| accepted

Answered

How do I create a loop that goes up by 5 until a certain number and then up by 3?

A simpler concept using |for|: s1 = 5; s2 = 3; V = 12:s1:31+s1; for k = [V,V(end)+s2:s2:50] ... end

How do I create a loop that goes up by 5 until a certain number and then up by 3?

A simpler concept using |for|: s1 = 5; s2 = 3; V = 12:s1:31+s1; for k = [V,V(end)+s2:s2:50] ... end

14 days ago | 0

Answered

How can I find number of words from a text file which ends with 'ed', 'es' and 'ing'?

It would be much simpler to use <https://www.mathworks.com/help/matlab/ref/regexp.html |regexp|>: >> str = fileread('sample...

How can I find number of words from a text file which ends with 'ed', 'es' and 'ing'?

It would be much simpler to use <https://www.mathworks.com/help/matlab/ref/regexp.html |regexp|>: >> str = fileread('sample...

14 days ago | 0

| accepted

Answered

How to reshape two matrices row wise with out changing the order

reshape([A,B]',1,[])

How to reshape two matrices row wise with out changing the order

reshape([A,B]',1,[])

15 days ago | 1

| accepted

Answered

Putting a matrix into an array

Into a 3D array: T = nan(4,4,N); T(:,:,1) = makehgtform('translate', [1,1,0]); T(:,:,2) = makehgtform('translate', [1...

Putting a matrix into an array

Into a 3D array: T = nan(4,4,N); T(:,:,1) = makehgtform('translate', [1,1,0]); T(:,:,2) = makehgtform('translate', [1...

16 days ago | 0

| accepted

Answered

Code to compare cells with a range in MATLAB

There is no point in writing MATLAB code like complex C++ code, with lots of loops and ifs. MATLAB code should be elegant, clear...

Code to compare cells with a range in MATLAB

There is no point in writing MATLAB code like complex C++ code, with lots of loops and ifs. MATLAB code should be elegant, clear...

16 days ago | 1

Answered

Recurring Sequences of Numbers

>> fun = @(N)round(cos((1:N)*pi/2)); >> fun(10) ans = 0 -1 0 1 0 -1 0 1 0 -1 >> fun(4) ans = ...

Recurring Sequences of Numbers

>> fun = @(N)round(cos((1:N)*pi/2)); >> fun(10) ans = 0 -1 0 1 0 -1 0 1 0 -1 >> fun(4) ans = ...

16 days ago | 0

| accepted

Answered

How to cross-reference values in one array with another (of different sizes)

ismember(Array1,Array2)

How to cross-reference values in one array with another (of different sizes)

ismember(Array1,Array2)

18 days ago | 0

| accepted

Answered

How to separate element in row with different length?

Two lines, no loop: >> a = {9611013;12811019;3211001;6411007;9611013;12811019;16011025;3211001;6411007;9611013;12811019;160...

How to separate element in row with different length?

Two lines, no loop: >> a = {9611013;12811019;3211001;6411007;9611013;12811019;16011025;3211001;6411007;9611013;12811019;160...

19 days ago | 1

Answered

Assignment help for MATLAB? Overall confusion and unable to interpret instructions fully, as well as code problems.

Take a deep breath, you are doing just fine! _"I don't know what's wrong and even I did, I doubt I'd know how to fix it."_ ...

Assignment help for MATLAB? Overall confusion and unable to interpret instructions fully, as well as code problems.

Take a deep breath, you are doing just fine! _"I don't know what's wrong and even I did, I doubt I'd know how to fix it."_ ...

19 days ago | 0

| accepted

Answered

How to plot row vectors in a matrix in which every marker is a different color and repeated amongst the other rows?

Because the markers and lines are perpendicular to each other (wrt. the input variables) it is not possible to define them both ...

How to plot row vectors in a matrix in which every marker is a different color and repeated amongst the other rows?

Because the markers and lines are perpendicular to each other (wrt. the input variables) it is not possible to define them both ...

20 days ago | 2

| accepted

Answered

Different variables depending on which file is loaded

Put the filename in a variable, and use |switch|: fnm = 'SIXRX2.txt'; S = load(fnm); ... switch fnm case 'S...

Different variables depending on which file is loaded

Put the filename in a variable, and use |switch|: fnm = 'SIXRX2.txt'; S = load(fnm); ... switch fnm case 'S...

20 days ago | 0

| accepted

Answered

if else statement problems

The problem is very simple: your code only loops over one value: for i = 10 Whereas you probably wanted to loop over te...

if else statement problems

The problem is very simple: your code only loops over one value: for i = 10 Whereas you probably wanted to loop over te...

20 days ago | 1

| accepted

Answered

Calling Functions from file names

S = dir(fullfile(myFolder,'models','*.m')); for k = 1:numel(S) [~,N] = fileparts(S(k).name); fun = str2func(N...

Calling Functions from file names

S = dir(fullfile(myFolder,'models','*.m')); for k = 1:numel(S) [~,N] = fileparts(S(k).name); fun = str2func(N...

20 days ago | 0

| accepted

Answered

Create a 3D matrix from multiple 1D vectors without FOR loop

St = zeros(3,3,L); St(1,1,:) = Sxxi; St(1,2,:) = Txyi; St(1,3,:) = Txzi; St(2,1,:) = Txyi; St(2,2,:) = Syyi; ...

Create a 3D matrix from multiple 1D vectors without FOR loop

St = zeros(3,3,L); St(1,1,:) = Sxxi; St(1,2,:) = Txyi; St(1,3,:) = Txzi; St(2,1,:) = Txyi; St(2,2,:) = Syyi; ...

20 days ago | 1

Answered

how to calculate the value?

You really need to learn the difference between matrix operations and array operations: <https://www.mathworks.com/help/matla...

how to calculate the value?

You really need to learn the difference between matrix operations and array operations: <https://www.mathworks.com/help/matla...

20 days ago | 1

| accepted

Answered

How do I find a file name containing a particular string in a given directory and read this present file and write into other folder.

*Method one: |strfind|:* P = 'E:\folder'; S = dir(fullfile(P,'*.jpg')); N = {S.name}; X = ~cellfun('isempty',strfi...

How do I find a file name containing a particular string in a given directory and read this present file and write into other folder.

*Method one: |strfind|:* P = 'E:\folder'; S = dir(fullfile(P,'*.jpg')); N = {S.name}; X = ~cellfun('isempty',strfi...

20 days ago | 0

Answered

Game of Life - my elements don't die, only grow!

Have a closer look at your logic operations: neighbours(row,col)==2||3 which is not an _error_, but it does not do what ...

Game of Life - my elements don't die, only grow!

Have a closer look at your logic operations: neighbours(row,col)==2||3 which is not an _error_, but it does not do what ...

21 days ago | 2

| accepted

Answered

My code creates files, uses them and then deletes them. The deletion part does not always work

Sometimes pausing helps, because OS operations do seem to take a finite amount of time: delete output.txt pause(1) rm...

My code creates files, uses them and then deletes them. The deletion part does not always work

Sometimes pausing helps, because OS operations do seem to take a finite amount of time: delete output.txt pause(1) rm...

21 days ago | 0

Answered

Question about logical calculation in matrix

Just use <https://www.mathworks.com/help/matlab/ref/accumarray.html |accumarray|>: >> AA = [0.2,1;0.3,1;0.5,2;0.9,2] AA ...

Question about logical calculation in matrix

Just use <https://www.mathworks.com/help/matlab/ref/accumarray.html |accumarray|>: >> AA = [0.2,1;0.3,1;0.5,2;0.9,2] AA ...

21 days ago | 1

Answered

When numerical data type changes while assigning new data?

_"Why is the behaviour different depending on the matrix size?"_ It doesn't, and there is nothing astonishing happening at al...

When numerical data type changes while assigning new data?

_"Why is the behaviour different depending on the matrix size?"_ It doesn't, and there is nothing astonishing happening at al...

21 days ago | 2

| accepted

Answered

z = str2num(all{n}(1:79)); is a piece of code that I'm using. all{} is 698x1 cell array. I'm trying to figure out if instead of using(1:79) if there as way of saying I need everything in the cell. Something like(:) to say I want all{}(:)?

Assuming that your data are stored in a text file of some sort, you should fix the problem at the source by simple importing you...

z = str2num(all{n}(1:79)); is a piece of code that I'm using. all{} is 698x1 cell array. I'm trying to figure out if instead of using(1:79) if there as way of saying I need everything in the cell. Something like(:) to say I want all{}(:)?

Assuming that your data are stored in a text file of some sort, you should fix the problem at the source by simple importing you...

21 days ago | 0

Answered

How to use multiple struct files using for loop

*Always |load| into a variable, then you avoid this problem entirely*. Assuming that your |.mat| files contain the same field...

How to use multiple struct files using for loop

*Always |load| into a variable, then you avoid this problem entirely*. Assuming that your |.mat| files contain the same field...

22 days ago | 0

Answered

I need to display the max value in this function.

Rather than enlarging the array on each iteration as KSSV showed (and in general is <https://www.mathworks.com/help/matlab/matla...

I need to display the max value in this function.

Rather than enlarging the array on each iteration as KSSV showed (and in general is <https://www.mathworks.com/help/matlab/matla...

22 days ago | 1