Answered
How to removing data of structure field?
>> st = struct('piece',{1,1,3,4},'food',{'cheerio','marshmallow','pizza','cereal'},'yes',{0,'food','no',0},'maybe',{'cereal',3,'...

7 years ago | 1

| accepted

Answered
Cropping image with actual pixel size
Do NOT use saveas. saveas is basically like taking a screenshot of a figure. Not very useful for your case. You need to use im...

7 years ago | 0

Answered
Iterating through an array without using a for loop
theta = 0:0.1:2*pi/5 theta(:) = rand(1,numel(theta))

7 years ago | 0

Answered
how to compare each elemnets in two cell with error tolerance?
>> A = {[1,2,3],[1.2,5,2.4]}; >> M = bsxfun(@rdivide,A{2},A{1}.'); >> [A1,A2] = find(abs(M-1)<=0.2) % 20% A1 = 1 ...

7 years ago | 0

| accepted

Answered
Extracting multiple sets of scientific notation data
Try this sscanf format string: '%d%f' However your file-importing code is rather complex. Here is a simpler method using texts...

7 years ago | 0

| accepted

Answered
split columns and save seperate .mat files
Simpler, much more robust, much more versatile code (without bad code practices such as dynamically accessed variable names, loa...

7 years ago | 0

| accepted

Answered
How to code below mathematical formula?
The simple MATLAB solution: >> x = 1:30; >> t = 23; % threshold >> MYOP = sum(x>=t)/numel(x) MYOP = 0.26667

7 years ago | 1

| accepted

Answered
Preallocate memory for the rows of each field inside a structure
This should get you started: >> S = struct('F',{[],[],[]}); >> S.F ans = [] ans = [] ans = [] >> [S.F] =...

7 years ago | 0

Answered
How can I save Python dictionaries in Matlab?
A simple approach: within MATLAB save the data in a .mat file. within Python load the data using numpy.io. rearrange the data...

7 years ago | 0

Answered
How to turn a column of seconds into the datetime-type?
The simple MATLAB solution using datetime and duration classes (no outdated datevec): T.TIME_S = zinterval + seconds(T.TIME_s) ...

7 years ago | 1

| accepted

Answered
Nested loop problem with the second index
The simple MATLAB way: >> cpx = [1,3,5,7]; >> cpy = [22,44,66]; >> [X,Y] = ndgrid(cpx,cpy); >> M = [X(:),Y(:)] M = 1 ...

7 years ago | 0

Answered
saving a variable from GUI
You forgot to actually pass those variables back to the main workspace: https://www.mathworks.com/help/matlab/creating_guis/sha...

7 years ago | 0

Answered
Diff matrix in cell array
Given one cell array A, this seems to matche your example: F = @(m)-diff(m,1,2); Y = cellfun(F,A,'uni',0)

7 years ago | 0

| accepted

Answered
Changing portions of variable names
Use this as the new filename: strrep(rawdata,'.csv','.dat') Or more robustly: [~,fnm] = fileparts(rawdata); sprintf('%s.dat'...

7 years ago | 0

| accepted

Answered
For loop pass in unique rows to function
M = [1,2.5,3,5;1,3,4,5;1,5,7,5;2,4,5,6;2,6,8,9]; U = unique(M(:,1)); for k = 1:numel(U) X = U(k)==M(:,1); yourFuncti...

7 years ago | 1

| accepted

Answered
cant find the mistake here
Well you made a good starting attempt, the main bug with your code are these ranges: for i = 1:a for j = 1:b Using those ...

7 years ago | 0

Answered
Append a char vector to a subset of cells (whose indices are known) in cell array of character vectors
Your basic concept is correct, you just need to use indexing on the LHS as well as the RHS: mycell(calidx_rng) = strcat('cal_',...

7 years ago | 1

| accepted

Answered
To check Scalar or Not
The reason is likely because of the order you check the inputs with, e.g.: fix(month) && isscalar(month) %^^^^^^^^^ ...

7 years ago | 1

| accepted

Answered
Not able to use plot function
plot is not the problem, the problem is that you used the wrong division. Replace / with ./ https://www.mathworks.com/help/...

7 years ago | 1

| accepted

Answered
Implementing mathematical functions in Matlab
>> x = 1.2; >> y = exp(log(x)) y = 1.2000 >> sind(30).^2 + cosd(30).^2 ans = 1

7 years ago | 0

| accepted

Answered
Strange error with use of the function."diff"
"...since it does not seem to be obvious at all. " On multiple lines of form2 you define a variable named diff, like this: dif...

7 years ago | 0

| accepted

Answered
when i add 's' when writing a program for matrix in script then there is no space between the eelements of any row
Wrap input in str2double: MATRIX(r,c) = str2double(input('...','s'));

7 years ago | 1

| accepted

Answered
How can i do loops (for cycles) with struct?
"... a matrix composed by struct (it is 1x91 cells, each one is a struct 1x1) ..." What you describe sounds like a 1x91 cell ar...

7 years ago | 0

| accepted

Answered
"Not enough input arguments" error using add_line()
"...i don't understnd why" Read the error message! According to the add_line documentation you can supply these input argument...

7 years ago | 0

Answered
How to remove empty fields from a struct?
a.bt(cellfun('isempty',a.bt)) = []

7 years ago | 0

Answered
String matrix compare to get common in rows
>> A1 = {'AA', 'b' ; 'cc', 'ff' ; 'tt', 'kk'; 'XX', 'b'; 'AA', 'b'}; >> A2 = {'ee', 'AA' ; 'hhh', 'm'; 'kk', 'o'; 'ee', 'XX'; '...

7 years ago | 0

| accepted

Answered
How can I determine the indices and length of consecutive non-NaN values in an array?
1) >> A = [NaN NaN NaN 10 22 NaN 33 28 21 NaN 20 98 NaN]; >> find(~isnan(A)) ans = 4 5 7 8 9 11 12 o...

7 years ago | 3

Answered
random number between 0 and 1
>> V = [zeros(1,100),ones(1,312)]; >> V = V(randperm(numel(V))); Checking: >> nnz(V==0) ans = 100 >> nnz(V==1) ans = 312...

7 years ago | 0

| accepted

Answered
How to Call multiple Database files and store the variables in them separately using loops?
% Fake data: amx = 1; ff = 11; save('12c1.mat','amx','ff') amx = 2; ff = 22; save('12c2.mat','amx','ff') clear % Main ...

7 years ago | 0

Answered
How can I add a workspace variable that is generated in a loop?
https://www.mathworks.com/help/matlab/matlab_prog/string-evaluation.html https://www.mathworks.com/matlabcentral/answers/304528...

7 years ago | 1

Load more