5,416 total contributions since 2014

Suspensa Vix Via Fit

Answered

Plotting based on a for loop from a cell array

xyz = 'XYZ'; figure() for k = 1:3 subplot(3,1,k) plot(UA_SEG{:,['Acc',xyz(k)]}) end https://www.mathworks.com/help...

Plotting based on a for loop from a cell array

xyz = 'XYZ'; figure() for k = 1:3 subplot(3,1,k) plot(UA_SEG{:,['Acc',xyz(k)]}) end https://www.mathworks.com/help...

4 hours ago | 0

| accepted

Answered

how to create a vector with the different sum of two elements of another vector?

No need to use a loop, some simple indexing works perfectly: >> v = [1,2,3,4,6,8]; >> v(1:2:end)+v(2:2:end) ans = 3 7...

how to create a vector with the different sum of two elements of another vector?

No need to use a loop, some simple indexing works perfectly: >> v = [1,2,3,4,6,8]; >> v(1:2:end)+v(2:2:end) ans = 3 7...

15 hours ago | 1

Answered

Save variable as string from user input

There are two overlapping issues here: The non-robustness of string evaluation (which was covered in your other question). Ther...

Save variable as string from user input

There are two overlapping issues here: The non-robustness of string evaluation (which was covered in your other question). Ther...

15 hours ago | 4

| accepted

Answered

is it possible to divide a decimal number into 3 decimal numbers?

>> N = 1000; >> R = 3; >> C = R+R*fix(log2(N)/R); >> M = reshape(dec2bin(N,C),[],R).' M = 0011 1110 1000 >> bin2dec(M) ...

is it possible to divide a decimal number into 3 decimal numbers?

>> N = 1000; >> R = 3; >> C = R+R*fix(log2(N)/R); >> M = reshape(dec2bin(N,C),[],R).' M = 0011 1110 1000 >> bin2dec(M) ...

1 day ago | 0

| accepted

Answered

MATLAB : How to keep output values after using return

"What should I do to pass the values of [S,r1,r2,c1,c2] to the caller function after using return?" Nothing special at all. As ...

MATLAB : How to keep output values after using return

"What should I do to pass the values of [S,r1,r2,c1,c2] to the caller function after using return?" Nothing special at all. As ...

1 day ago | 0

Answered

How to read the details of a '1×1 struct' Cell Array?

Both cell arrays and structure arrays are kinds of container arrays, i.e. they can contain other arrays. In your case you actual...

How to read the details of a '1×1 struct' Cell Array?

Both cell arrays and structure arrays are kinds of container arrays, i.e. they can contain other arrays. In your case you actual...

1 day ago | 0

| accepted

Answered

How can I call the variables of MATLAB workspace from a function?

"I don't seem to be able to do it when I am inside a funtion and don't know the name of the variables prior to running the progr...

How can I call the variables of MATLAB workspace from a function?

"I don't seem to be able to do it when I am inside a funtion and don't know the name of the variables prior to running the progr...

3 days ago | 0

Answered

Sort first column of a 5x2 matrix but keep the rows intact after sorting

Use sortrows: >> V = [13,11,15,26,20]; >> M = [V;1:numel(V)].' M = 13 1 11 2 15 3 26 4 20 ...

Sort first column of a 5x2 matrix but keep the rows intact after sorting

Use sortrows: >> V = [13,11,15,26,20]; >> M = [V;1:numel(V)].' M = 13 1 11 2 15 3 26 4 20 ...

3 days ago | 0

| accepted

Answered

How to iteratively add elements to a cell array without clearing previous elements?

I suspect that you forgot to actually store the handles data after you made changes to it. The handles structure inside the call...

How to iteratively add elements to a cell array without clearing previous elements?

I suspect that you forgot to actually store the handles data after you made changes to it. The handles structure inside the call...

3 days ago | 0

Answered

Splitting Cell Arrays by Delimiter

There is no need to split, just count the commas, e.g.: >> s = {'AAAA,BBBB'; 'CCCC,DDDD,EEEE'; 'FFFF'}; >> n = 1+cellfun(@nume...

Splitting Cell Arrays by Delimiter

There is no need to split, just count the commas, e.g.: >> s = {'AAAA,BBBB'; 'CCCC,DDDD,EEEE'; 'FFFF'}; >> n = 1+cellfun(@nume...

4 days ago | 0

Answered

Converting a printed set of data to a structure or structure array

The simplest solution that satisfies your description: S = load('olympics.mat','gold', 'silver', 'bronze', 'countries');

Converting a printed set of data to a structure or structure array

The simplest solution that satisfies your description: S = load('olympics.mat','gold', 'silver', 'bronze', 'countries');

4 days ago | 0

Answered

Shifting position of an element in a vector from 1st to last

Here is a general solution for any sized vector (not in a single command though): >> N = 5; >> V = 1:N V = 1 2 3 4 ...

Shifting position of an element in a vector from 1st to last

Here is a general solution for any sized vector (not in a single command though): >> N = 5; >> V = 1:N V = 1 2 3 4 ...

4 days ago | 1

| accepted

Answered

NEED HELP! in load a text file containing the first one million digits of Pi.

This code imports all of the digits in around one second: >> fid = fopen('data.txt','rt'); >> vec = fscanf(fid,'%1d'); >> fcl...

NEED HELP! in load a text file containing the first one million digits of Pi.

This code imports all of the digits in around one second: >> fid = fopen('data.txt','rt'); >> vec = fscanf(fid,'%1d'); >> fcl...

4 days ago | 1

| accepted

Answered

Vectorization of for loop

In three lines, no loop: >> new_im = flipped_im; >> idx = new_im(:,:,1)>new_im(:,:,2) | new_im(:,:,1)>new_im(:,:,3); >> new_i...

Vectorization of for loop

In three lines, no loop: >> new_im = flipped_im; >> idx = new_im(:,:,1)>new_im(:,:,2) | new_im(:,:,1)>new_im(:,:,3); >> new_i...

4 days ago | 1

| accepted

Submitted

Maximally Distinct Color Generator

Generate truly maximally distinct colors in an RGB colormap, using CAM02 colorspace (much better than CIELAB).

5 days ago | 40 downloads |

Answered

How do you save variables to vectors and plot them?

You define h to have values that are NOT positive integer: for h=0:.5:105 which means that you cannot use h as an index. The s...

How do you save variables to vectors and plot them?

You define h to have values that are NOT positive integer: for h=0:.5:105 which means that you cannot use h as an index. The s...

5 days ago | 0

Answered

equality between different number of variables problem

Where C is your cell array: isequal(C{:}) Learn how this works by reading the isequal documentation, and these: https://www.m...

equality between different number of variables problem

Where C is your cell array: isequal(C{:}) Learn how this works by reading the isequal documentation, and these: https://www.m...

5 days ago | 0

| accepted

Answered

How to hide alphabets behind asterisks for password in GUI?(Creating GUI using guide)

Note that MATLAB is not a secure tool suitable for handling passwords: any arbitrary function can be trivially overloaded. http...

How to hide alphabets behind asterisks for password in GUI?(Creating GUI using guide)

Note that MATLAB is not a secure tool suitable for handling passwords: any arbitrary function can be trivially overloaded. http...

6 days ago | 2

Answered

How do I load data files starting wih strings?

>> str = fileread('temp.txt'); >> str = regexprep(str,'\s+',''); >> mat = reshape(sscanf(str,'x%fy%f'),2,[]).' mat = 0 ...

How do I load data files starting wih strings?

>> str = fileread('temp.txt'); >> str = regexprep(str,'\s+',''); >> mat = reshape(sscanf(str,'x%fy%f'),2,[]).' mat = 0 ...

6 days ago | 1

Answered

how to sum of each row according to values values in given function

Simpler: >> X = [1,0,1,0,0,1;1,0,0,1,0,1;1,0,0,0,1,1;1,0,0,1,1,1;0,1,1,0,0,1] X = 1 0 1 0 0 1 1 0 0 ...

how to sum of each row according to values values in given function

Simpler: >> X = [1,0,1,0,0,1;1,0,0,1,0,1;1,0,0,0,1,1;1,0,0,1,1,1;0,1,1,0,0,1] X = 1 0 1 0 0 1 1 0 0 ...

6 days ago | 2

Answered

get file name from other directory

The problem is on this line: fullFileName= fullfile(folder,fullFileName.name) % ^^^^^^^^^^^^^^^^^ ...

get file name from other directory

The problem is on this line: fullFileName= fullfile(folder,fullFileName.name) % ^^^^^^^^^^^^^^^^^ ...

7 days ago | 0

| accepted

Answered

Replace a block of strings in a text file with another string

One way is to use a regular expression, which even lets you keep the EOL characters exactly the same: rgx = 'ADDRESS(\s+)[^/]+/...

Replace a block of strings in a text file with another string

One way is to use a regular expression, which even lets you keep the EOL characters exactly the same: rgx = 'ADDRESS(\s+)[^/]+/...

7 days ago | 0

Answered

Help with making a function.

function y = myfun(x) y = sqrt(x); if y~=fix(y) y = floor(x/3); end end

Help with making a function.

function y = myfun(x) y = sqrt(x); if y~=fix(y) y = floor(x/3); end end

7 days ago | 0

Answered

how to round off a number to the nearest multiple of 25?

>> a = 254; >> 25*ceil(a/25) ans = 275

how to round off a number to the nearest multiple of 25?

>> a = 254; >> 25*ceil(a/25) ans = 275

8 days ago | 0

Answered

Given an element of a matrix, How to print all the arrays containing that element?

This should get you started, adjust as required: >> A = magic(4) A = 16 2 3 13 5 11 10 8 9 7 ...

Given an element of a matrix, How to print all the arrays containing that element?

This should get you started, adjust as required: >> A = magic(4) A = 16 2 3 13 5 11 10 8 9 7 ...

8 days ago | 0

Answered

Reading in text file using textscan.

textscan imports file data into one cell array, the contents of which are one or more arrays (numeric, cell, datetime, etc), whe...

Reading in text file using textscan.

textscan imports file data into one cell array, the contents of which are one or more arrays (numeric, cell, datetime, etc), whe...

8 days ago | 0

| accepted

Answered

How to plot a function, instead of just values?

>> X = linspace(-8,8,500); >> Y = fresnelS(@(x) sin(x.^2), X, 50); >> plot(X,Y)

How to plot a function, instead of just values?

>> X = linspace(-8,8,500); >> Y = fresnelS(@(x) sin(x.^2), X, 50); >> plot(X,Y)

10 days ago | 0

| accepted

Answered

Append values from textscan into cell array literately in a loop

>> str = fileread('test.txt'); >> reshape(sscanf(str,'%*[^=]=%f'),3,[]).' ans = 20 120 65 21 121 63 1...

Append values from textscan into cell array literately in a loop

>> str = fileread('test.txt'); >> reshape(sscanf(str,'%*[^=]=%f'),3,[]).' ans = 20 120 65 21 121 63 1...

10 days ago | 0

| accepted

Answered

moving files from one folder to an other

All files: A = '/media/my_name/data/*.mat' B = '/media/my_name/moved_files' movefile(A,B) Tenth file: A = '/media/my_name/d...

moving files from one folder to an other

All files: A = '/media/my_name/data/*.mat' B = '/media/my_name/moved_files' movefile(A,B) Tenth file: A = '/media/my_name/d...

10 days ago | 1

| accepted

Answered

Replace some elements in a Matrices with brief code.

>> a = [5,6,7,9,1,2,5,6,3,8,9,0]; >> x = [1,3,6,2;2,4,1,9;2,3,5,6]; >> b = a(x); >> y = b>=6; >> b(y) = x(y) b = 5 3 ...

Replace some elements in a Matrices with brief code.

>> a = [5,6,7,9,1,2,5,6,3,8,9,0]; >> x = [1,3,6,2;2,4,1,9;2,3,5,6]; >> b = a(x); >> y = b>=6; >> b(y) = x(y) b = 5 3 ...

10 days ago | 1

| accepted