Answered
Error when taking an exponent from a large data set
x2 = exp(double(x1));

7 years ago | 0

Answered
how to avoid using a name to a specific file in GUI
Your explanation is not clear if you know Specificname in advance or not, or how many variables there are saved in the .mat file...

7 years ago | 0

| accepted

Answered
Import .txt and save as .mat with conditions
As you did not supply an example file I created my own (attached). [fid,msg] = fopen('test.txt','rt'); assert(fid>=3,msg) C =...

7 years ago | 0

| accepted

Answered
convert milliseconds (ms) to seconds (s)
You can change the format of how numbers are displayed, e.g. "shortG" >> format shortG >> ms/1000 ans = 1600.9 ...

7 years ago | 1

| accepted

Answered
From a given vector create all combinations possible
>> V = [5,10,15]; >> [X,Y] = ndgrid(V); >> M = [Y(:),X(:)] M = 5 5 5 10 5 15 10 5 10 10 ...

7 years ago | 0

| accepted

Answered
Finding values of specific range from table row or column
>> A = [12345 NaN NaN NaN NaN 457 NaN NaN NaN 785 NaN NaN NaN NaN NaN NaN 74502].' A = 12345 NaN NaN NaN NaN ...

7 years ago | 2

| accepted

Answered
Regular Expression to timestamp
>> rgx = '(?<H>\d*)(?(1):)(?<M>\d+):(?<S>\d+)\.(?<F>\d+)'; >> regexp('11:32.456',rgx,'names') ans = H: '' M: '11' ...

7 years ago | 0

Answered
Rescaling a variable with NaNs
>> M = randi(7,3,5); >> M(randi(numel(M),1,3)) = NaN M = 6 7 7 6 4 3 NaN 5 NaN 6 ...

7 years ago | 1

| accepted

Answered
how to remove the last column in the matrix?
>> A = [2,4,2,4,2,6,8] A = 2 4 2 4 2 6 8 >> B = A(1:end-1) B = 2 4 2 4 2 6

7 years ago | 0

| accepted

Answered
Fill an array after a for loop
These two changes make the code run without error: G = zeros(nraw,numel(x)); and G(i,:) = x; Whether it is correct only you ...

7 years ago | 0

| accepted

Answered
Convert a vector in Character array after a for loop
Avoiding character manipulations using basic indexing: >> x = [1,2,3,1]; >> V = 'A':'Z'; >> V(x) ans = ABCA

7 years ago | 0

| accepted

Answered
How to define and store string to matrix or array
With a simple cell array: N = 3; C = cell(1,N); for k = 1:N x = ... your code C{k} = x; end https://www.mathworks...

7 years ago | 3

| accepted

Answered
draw a graph from cell arrays
plot((Y{i},position);); % ^ ^^ not valid syntax should be plot(Y{i},position); PS: in future please show th...

7 years ago | 0

Answered
Round in a cell array that also contains string
idx = cellfun(@isnumeric,C); C(idx) = cellfun(@(x)round(x,N),C(idx),'uni',0)

7 years ago | 0

| accepted

Answered
How can I generate random single precision (float32) numbers ?
This generates all possible singles: >> V = ['0':'9','A':'F']; >> X = randi(16,1,8); >> V(X) ans = 7B3A5B5F >> N = typecast...

7 years ago | 1

Answered
How can I create a fullpath from images of different subfolders?
Do not use path as a variable name (you shadow the inbuilt function of that name). Do not concatenate strings to build paths. ...

7 years ago | 0

| accepted

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

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

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

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

7 years ago | 0

Answered
how to stop changing of a variable?
Use a nested function: logic = true; ... function ... ... logic = logic && s<200; ... end ... Or a ...

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

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

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

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

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

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

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

7 years 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'

7 years ago | 1

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

7 years ago | 0

| accepted

Load more