Answered

Using a Variable inside the name to save a file

fnm = sprintf('date_%s_task.jpg',ID); saveas(gcf,fnm); Note that obtaining and referring to explicit graphics handles is more ...

Using a Variable inside the name to save a file

fnm = sprintf('date_%s_task.jpg',ID); saveas(gcf,fnm); Note that obtaining and referring to explicit graphics handles is more ...

29 Tage ago | 0

Answered

the logical answer is 1

The MATLAB Editor will highlight assignments without a semi-colon: https://www.mathworks.com/help/matlab/matlab_prog/check-code...

the logical answer is 1

The MATLAB Editor will highlight assignments without a semi-colon: https://www.mathworks.com/help/matlab/matlab_prog/check-code...

29 Tage ago | 0

Answered

How to resize a matrix with zeros in between elements

Some general solutions for matrix A of any size. >> A = [10,5;4,10;2,3]; Method one: sub2ind: >> [R,C] = size(A); >> B = zer...

How to resize a matrix with zeros in between elements

Some general solutions for matrix A of any size. >> A = [10,5;4,10;2,3]; Method one: sub2ind: >> [R,C] = size(A); >> B = zer...

29 Tage ago | 2

| accepted

Answered

Transform a 3D dimension array to n 2D matrix

"How can I transform a 3D dimension array (15*781*81) to 15 extracted 781*81 2D matrix to make it feasible to write down them in...

Transform a 3D dimension array to n 2D matrix

"How can I transform a 3D dimension array (15*781*81) to 15 extracted 781*81 2D matrix to make it feasible to write down them in...

29 Tage ago | 0

Answered

how to stop changing of a variable?

Use a nested function: logic = true; ... function ... ... logic = logic && s<200; ... end ... Or a ...

how to stop changing of a variable?

Use a nested function: logic = true; ... function ... ... logic = logic && s<200; ... end ... Or a ...

29 Tage ago | 0

| accepted

Answered

All possible permutation of a given vector.

V = [1,2,3,4,1]; N = numel(V); % Permutations: P = perms(V(2:N)); P(:,N) = V(1); P = unique(P,'rows') % Rotations: R = P;...

All possible permutation of a given vector.

V = [1,2,3,4,1]; N = numel(V); % Permutations: P = perms(V(2:N)); P(:,N) = V(1); P = unique(P,'rows') % Rotations: R = P;...

30 Tage ago | 0

| accepted

Answered

Finding the average of every nth row but n is not fixed.

>> M = [1,10;1,11;1,20;2,4;2,9;2,8;2,8]; Method one: accumarray: >> V = accumarray(M(:,1),M(:,2),[],@mean) V = 13.667 ...

Finding the average of every nth row but n is not fixed.

>> M = [1,10;1,11;1,20;2,4;2,9;2,8;2,8]; Method one: accumarray: >> V = accumarray(M(:,1),M(:,2),[],@mean) V = 13.667 ...

30 Tage ago | 0

| accepted

Answered

wildcard in dir command - single char

dir does not support single-character wildcards. You could remove the superfluous filenames afterwards, e.g.: >> S = dir('aaa*...

wildcard in dir command - single char

dir does not support single-character wildcards. You could remove the superfluous filenames afterwards, e.g.: >> S = dir('aaa*...

30 Tage ago | 0

Answered

How to assign few of the array values with a constant randomly .

"How to assign few of the array values with a constant randomly ." >> n = 10; >> m = 4; >> V = zeros(1,n); % generate array ...

How to assign few of the array values with a constant randomly .

"How to assign few of the array values with a constant randomly ." >> n = 10; >> m = 4; >> V = zeros(1,n); % generate array ...

30 Tage ago | 1

| accepted

Answered

Why "undefined variable" error keeps coming when infact the variable is defined?

stats is empty so your loop never runs (i.e. the code inside the loop never runs so those variables are not defined). This occur...

Why "undefined variable" error keeps coming when infact the variable is defined?

stats is empty so your loop never runs (i.e. the code inside the loop never runs so those variables are not defined). This occur...

30 Tage ago | 0

Answered

Transforming HH:mm:SS to 'dd.MM.yy HH:mm:SS' and loosing seconds

"I would like to add current date to the 'time'" Sure, that is easy, by just adding a duration object to a datetime object. Yo...

Transforming HH:mm:SS to 'dd.MM.yy HH:mm:SS' and loosing seconds

"I would like to add current date to the 'time'" Sure, that is easy, by just adding a duration object to a datetime object. Yo...

etwa ein Monat ago | 0

| accepted

Answered

How to create a .mat file

"How to create a .mat file" Use save, which is the MATLAB command explicitly designed to write .mat files. "I need to create a...

How to create a .mat file

"How to create a .mat file" Use save, which is the MATLAB command explicitly designed to write .mat files. "I need to create a...

etwa ein Monat ago | 0

| accepted

Answered

Splitting based on delimiter but only once

>> S = 'Country ˈk ʌ n t r i'; >> C = regexp(S,' ','split','once') C = 'Country' 'ˈk ʌ n t r i'

Splitting based on delimiter but only once

>> S = 'Country ˈk ʌ n t r i'; >> C = regexp(S,' ','split','once') C = 'Country' 'ˈk ʌ n t r i'

etwa ein Monat ago | 0

Answered

how to use a file from a different directory?

Use fullfile to build the full filename: function B(dirName) N = inifile(fullfile(dirName,'c.ini'),90) ... end

how to use a file from a different directory?

Use fullfile to build the full filename: function B(dirName) N = inifile(fullfile(dirName,'c.ini'),90) ... end

etwa ein Monat ago | 0

| accepted

Answered

Putting the result from eval into a cell array

N = 600; C = cell(1,N); % preallocate. for k = 1:N G = [F(k)+1,F(k+1)]; % you never use G anywhere in your code... C...

Putting the result from eval into a cell array

N = 600; C = cell(1,N); % preallocate. for k = 1:N G = [F(k)+1,F(k+1)]; % you never use G anywhere in your code... C...

etwa ein Monat ago | 0

Answered

How can I import repeating blocks of mixed data as a table?

This imports and parses your example file: str = fileread('Data.txt'); str = regexprep(str,{'= ','[\r\n]+SNC','[\r\n]+'...

How can I import repeating blocks of mixed data as a table?

This imports and parses your example file: str = fileread('Data.txt'); str = regexprep(str,{'= ','[\r\n]+SNC','[\r\n]+'...

etwa ein Monat ago | 2

| accepted

Answered

How might I terminate a for loop based on an if statement?

doc break

How might I terminate a for loop based on an if statement?

doc break

etwa ein Monat ago | 0

Answered

How to illustrate a cell array

There are no doubt many ways of doing this, one relatively intuitive way would be to use scatter. This should get you started (b...

How to illustrate a cell array

There are no doubt many ways of doing this, one relatively intuitive way would be to use scatter. This should get you started (b...

etwa ein Monat ago | 1

| accepted

Answered

How do I use sprintf with two variables with different sizes?

Assuming that you have nested structures, then you can easily do something like this: >> s(1).rawdata.data00 = 100; >> s(1).ra...

How do I use sprintf with two variables with different sizes?

Assuming that you have nested structures, then you can easily do something like this: >> s(1).rawdata.data00 = 100; >> s(1).ra...

etwa ein Monat ago | 0

| accepted

Answered

Color and brightness in imread

Your image is actually an indexed image, not a grayscale image, and this is easy to find out using the inbuilt imfinfo: >> imfi...

Color and brightness in imread

Your image is actually an indexed image, not a grayscale image, and this is easy to find out using the inbuilt imfinfo: >> imfi...

etwa ein Monat ago | 0

| accepted

Answered

How to remove everything from string except what's inside square brackets?

Where C is your cell array: >> D = regexp(C,'\[(.+)\]','tokens','once') >> D = vertcat(D{:}) D = 'rpm' 'rpm' ...

How to remove everything from string except what's inside square brackets?

Where C is your cell array: >> D = regexp(C,'\[(.+)\]','tokens','once') >> D = vertcat(D{:}) D = 'rpm' 'rpm' ...

etwa ein Monat ago | 0

Answered

Exponent on top or on the right of the axis, control, turn off?

Either set the number format or the exponent: https://www.mathworks.com/help/matlab/creating_plots/change-tick-marks-and-tick-l...

Exponent on top or on the right of the axis, control, turn off?

Either set the number format or the exponent: https://www.mathworks.com/help/matlab/creating_plots/change-tick-marks-and-tick-l...

etwa ein Monat ago | 1

| accepted

Answered

ismember(A,B,'rows') indexing

>> one = {'ADSµSOIC8';'AVX0603';'ELN';'ELNH10';'EPC';'EPC0603';'FAGDO214AA';'FAGDO214AA (SMB)';'FAGDO214AB';'FAGDO214AC';'FAGSMA...

ismember(A,B,'rows') indexing

>> one = {'ADSµSOIC8';'AVX0603';'ELN';'ELNH10';'EPC';'EPC0603';'FAGDO214AA';'FAGDO214AA (SMB)';'FAGDO214AB';'FAGDO214AC';'FAGSMA...

etwa ein Monat ago | 1

| accepted

Answered

Error using ^ Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To perform elementwise matrix powers, use '.^'. Error in Untitled (line 23) D(i) = sqrt ((a1(i)-a9)^2 +(b1(i)-b9)^2 + (c

Using my trusty magical crystal ball: a1 = 550; b1 = 355; c1 = 0.5676; d1 = 1.3090; a9 = Data(:,1); b9 = Data(:,2); c9...

Error using ^ Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To perform elementwise matrix powers, use '.^'. Error in Untitled (line 23) D(i) = sqrt ((a1(i)-a9)^2 +(b1(i)-b9)^2 + (c

Using my trusty magical crystal ball: a1 = 550; b1 = 355; c1 = 0.5676; d1 = 1.3090; a9 = Data(:,1); b9 = Data(:,2); c9...

etwa ein Monat ago | 1

Answered

Write a function called picker that takes three input arguments called condition, in1 and in2 in this order. The argument condition is a logical. If it is true, the function assigns the value of in1 to the output argument out, otherwise, it assigns

function [cd,a,b]=picker(cd,a,b); if picker(a<b,a,b) fprintf('out=a'); else fprintf('out=b') end Your function ign...

Write a function called picker that takes three input arguments called condition, in1 and in2 in this order. The argument condition is a logical. If it is true, the function assigns the value of in1 to the output argument out, otherwise, it assigns

function [cd,a,b]=picker(cd,a,b); if picker(a<b,a,b) fprintf('out=a'); else fprintf('out=b') end Your function ign...

etwa ein Monat ago | 0

Answered

How can I make a single plot that consists of multiple lines, each made from every n rows of a vector?

"I'm sure I will need to use a loop because I won't be able to do this manually for a 300,000 x 2 set of data." I don't see why...

How can I make a single plot that consists of multiple lines, each made from every n rows of a vector?

"I'm sure I will need to use a loop because I won't be able to do this manually for a 300,000 x 2 set of data." I don't see why...

etwa ein Monat ago | 0

| accepted

Answered

logaritmical spacing / incremented spacing

>> diff(fix(log2((1:32).'))) ans = 1 0 1 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 ...

logaritmical spacing / incremented spacing

>> diff(fix(log2((1:32).'))) ans = 1 0 1 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 ...

etwa ein Monat ago | 1

| accepted

Answered

Transferring data from a cell array to a vector

"can i convert this data into vector?" >> Atlas = {122,12} ; >> vec = [Atlas{:}] vec = 122 12 https://www.mathworks.c...

Transferring data from a cell array to a vector

"can i convert this data into vector?" >> Atlas = {122,12} ; >> vec = [Atlas{:}] vec = 122 12 https://www.mathworks.c...

etwa ein Monat ago | 0

Answered

Split string into string based on character type

>> S = '1A2'; >> C = regexp(S,'(\d+)(\D+)(\d+)','tokens','once') C = '1' 'A' '2'

Split string into string based on character type

>> S = '1A2'; >> C = regexp(S,'(\d+)(\D+)(\d+)','tokens','once') C = '1' 'A' '2'

etwa ein Monat ago | 0

| accepted

Answered

How to append cell arrays with a very specific form

As long as your data meet some assumptions: each group contains exactly the same number of rows (four in your example), and ea...

How to append cell arrays with a very specific form

As long as your data meet some assumptions: each group contains exactly the same number of rows (four in your example), and ea...

etwa ein Monat ago | 1

| accepted