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

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

29 Tage ago | 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

etwa ein Monat ago | 0

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

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

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

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

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

ismember(A,B,'rows') indexing

etwa ein Monat ago | 1

| accepted

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

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

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

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