5.430 total contributions since 2014

Suspensa Vix Via Fit

Answered

Indice wise reference of indice from another matrix

Use ndgrid and sub2ind: >> A = [0,1;1,1]; >> D = [1,1;2,3]; >> B = zeros(2,2,3); >> S = size(B); >> [R,C] = ndgrid(1:S(1),1...

Indice wise reference of indice from another matrix

Use ndgrid and sub2ind: >> A = [0,1;1,1]; >> D = [1,1;2,3]; >> B = zeros(2,2,3); >> S = size(B); >> [R,C] = ndgrid(1:S(1),1...

etwa 22 Stunden ago | 0

| accepted

Answered

Convert time to datenum

It is not required to navigate to data directories to read data: D = 'Path of the directory where the MAT files are saved'; S ...

Convert time to datenum

It is not required to navigate to data directories to read data: D = 'Path of the directory where the MAT files are saved'; S ...

etwa 22 Stunden ago | 1

| accepted

Answered

Multidimensional matrix to use for loop

for k = 1:3 X(:,:,k) end If you want to split into a cell array: a = cell(1,3); for k = 1:3 a{k} = X(:,:,k) end ...

Multidimensional matrix to use for loop

for k = 1:3 X(:,:,k) end If you want to split into a cell array: a = cell(1,3); for k = 1:3 a{k} = X(:,:,k) end ...

4 Tage ago | 0

Answered

How to make a for loop with matrices using n?

>> n = 10; >> A = toeplitz([2,-1,zeros(1,n-2)]) A = 2 -1 0 0 0 0 0 0 0 0 -1 2 -1 0 0 0 0 ...

How to make a for loop with matrices using n?

>> n = 10; >> A = toeplitz([2,-1,zeros(1,n-2)]) A = 2 -1 0 0 0 0 0 0 0 0 -1 2 -1 0 0 0 0 ...

4 Tage ago | 0

| accepted

Answered

Rename a variable using a string

"Rename a variable using a string" Why bother? Both load and save work with scalar structures, which makes your task easy: S =...

Rename a variable using a string

"Rename a variable using a string" Why bother? Both load and save work with scalar structures, which makes your task easy: S =...

4 Tage ago | 0

| accepted

Answered

Matlab plots my equation wrong

MATLAB has plotted exactly what you asked for, where the y-range ranges over: >> x = -20:0.1:20; >> y = x.^10-1; >> max(y) a...

Matlab plots my equation wrong

MATLAB has plotted exactly what you asked for, where the y-range ranges over: >> x = -20:0.1:20; >> y = x.^10-1; >> max(y) a...

4 Tage ago | 1

| accepted

Answered

what does this code represents? and why rand() has no value between parentheses?

It defines a function which returns either 1 or 0, where 1 has ~=20% probability. Simpler code: customer = @()+(rand(1)<=0.2); ...

what does this code represents? and why rand() has no value between parentheses?

It defines a function which returns either 1 or 0, where 1 has ~=20% probability. Simpler code: customer = @()+(rand(1)<=0.2); ...

4 Tage ago | 0

| accepted

Answered

please in need help , how can i get all the possibile combination 111 112 121 122 211 212 221 222 for matrix A in matlab , than u

>> R = [0.5807,0.5192;0.879,1.5083;0.6836,1.5183] R = 0.5807 0.5192 0.8790 1.5083 0.6836 1.5183 >> [X,Y,Z] = ndgri...

please in need help , how can i get all the possibile combination 111 112 121 122 211 212 221 222 for matrix A in matlab , than u

>> R = [0.5807,0.5192;0.879,1.5083;0.6836,1.5183] R = 0.5807 0.5192 0.8790 1.5083 0.6836 1.5183 >> [X,Y,Z] = ndgri...

4 Tage ago | 0

Answered

How can I get and write data from text file?

This code sorts the file data into one cell array C, where each cell in C contains the summer data for one year. The summer star...

How can I get and write data from text file?

This code sorts the file data into one cell array C, where each cell in C contains the summer data for one year. The summer star...

4 Tage ago | 0

| accepted

Answered

Error using cat. Dimensions of arrays being concatenated are not consistent.

That is not very well designed code: the regexp is overkill, and the str2num with cellfun is likely not very efficient (as well ...

Error using cat. Dimensions of arrays being concatenated are not consistent.

That is not very well designed code: the regexp is overkill, and the str2num with cellfun is likely not very efficient (as well ...

4 Tage ago | 1

| accepted

Answered

Error: Cannot convert double value 5 to a handle

Most likely sch(ii,1), ii, and h are actually all different classes which cannot be concatenated together. You could easily use...

Error: Cannot convert double value 5 to a handle

Most likely sch(ii,1), ii, and h are actually all different classes which cannot be concatenated together. You could easily use...

4 Tage ago | 0

| accepted

Answered

add zero elemant inside cell

Simple indexing does exactly what you need: >> A={[95],[112],[98],[84],[69],[121],[108]}; >> B={[1,2,4],[4,3],[6,9,98],[3,7,88...

add zero elemant inside cell

Simple indexing does exactly what you need: >> A={[95],[112],[98],[84],[69],[121],[108]}; >> B={[1,2,4],[4,3],[6,9,98],[3,7,88...

4 Tage ago | 0

| accepted

Answered

How do I find closest values between 2 matrices?

Using basic MATLAB only (i.e. without knnsearch from the Statistics Toolbox): >> true_ang = [-40,-20]; >> all_angs = [30.80304...

How do I find closest values between 2 matrices?

Using basic MATLAB only (i.e. without knnsearch from the Statistics Toolbox): >> true_ang = [-40,-20]; >> all_angs = [30.80304...

6 Tage ago | 0

Answered

Passing by reference vs value

"Passing by reference vs value" Neither. MATLAB is more intelligent that either of those. MATLAB uses something called "copy on...

Passing by reference vs value

"Passing by reference vs value" Neither. MATLAB is more intelligent that either of those. MATLAB uses something called "copy on...

7 Tage ago | 0

| accepted

Submitted

Convert between RGB and Color Names

RGB to color name. Color name to RGB. Palettes: CSS, HTML, MATLAB, SVG, X11, xcolor, xkcd,...

8 Tage ago | 30 downloads |

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

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

8 Tage ago | 1

| accepted

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

8 Tage 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) ...

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

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

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

10 Tage ago | 1

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

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

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

11 Tage 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');

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

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

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

12 Tage ago | 1

| accepted

Submitted

Maximally Distinct Color Generator

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

12 Tage ago | 34 downloads |