Respondida
How to assign a value to a variable in for loop?
This is the most frequently asked question from beginners. Professional programmers give the simple and not expected answer: Don...

más de 3 años hace | 0

| aceptada

Respondida
How to save all the images generated from the for loop?
Remove the line f=figure; at the bottom of the loop, but open a new figure on top: for i=1:length(fileList) FigH = =figu...

más de 3 años hace | 0

| aceptada

Respondida
Proper if/else statement in appdesigner
Ref = app.rr_camber_ref.Value; Value = app.rr_camber.Value; if abs(Value - Ref) / abs(Ref) < 0.05 app.Lamp_rr_camber.Co...

más de 3 años hace | 1

| aceptada

Respondida
How do I change the font type in the axes?
Ax1H = subplot(1,2,1); Ax1H.FontName = 'Serif'; Ax1H.FontSize = 15; Ax2H = subplot(1,2,2); Ax2H.FontName = 'SansSerif'; Ax2...

más de 3 años hace | 0

Respondida
Match two columns with names/strings that are not 100% identical
Pool = {'NAME123ABC', 'NAME2XYZ', 'NAME3333', 'NAME ZZZ'} Data = {'XYZ', 'Name1ABC', 'abc', '123A', 'AAA', 'ABC ABC', 'Name1 AB...

más de 3 años hace | 0

Respondida
Matlab takes long time to start, also it lags so much and windows task manager shows very high memory usage. How to fix this?
Do you really need all toolboxes? This is a massive overkill. You can run the installer again and deselect the toolboxes, you d...

más de 3 años hace | 1

Respondida
Processing each data automatically in a loop
If you do not want to call uigetfile, remove this command: pathname = 'C:\Your\Folder'; for i = 0:287 filename = fullfile...

más de 3 años hace | 0

| aceptada

Respondida
For loop skipping with if statement
This is a linear interpolation. This is implemented without a loop already: pk = [1, 2; 3, 0; 4, 0; 5, 3; 7, 2; 10, 0; 13, 5]; ...

más de 3 años hace | 0

Respondida
How to run a function within another function with specified input?
Convert the scripts S1 and S2 to functions, which accept these inputs. Then: x3 = get(handles.cbS2,'Value'); x4 = get(handles....

más de 3 años hace | 0

| aceptada

Respondida
Structure of array: deletion of null elements
S = exp_value; % Just for readability remove = (S.f_avg(:, 1) == 0); fields = setdiff(fieldnames(S), {'f_avg'}); % All...

más de 3 años hace | 0

| aceptada

Respondida
Naming tables inside a for loop
This is the most frequently asked question in this forum. The answer is easy: Don't do this. It is a shot in your knee. See: TU...

más de 3 años hace | 0

| aceptada

Respondida
How to programmatically delete a folder with content to recycle bin as a whole
Using another folder instead of the recycle bin has severe advantages: The recycle bin fails, if the path name of the deleted f...

más de 3 años hace | 0

Respondida
Running Average of a large data set
A = readmatrix(filename); A(:, 3) = movmean(A(:, 2), 101);

más de 3 años hace | 0

Respondida
Problems converting folders in a directory from cell array into individual nested structures.
The field names cannot contain a dot. Remove the dots: ... for i = 1:length(subFolderNames) name = strrep(Folders(i).Fold...

casi 4 años hace | 0

| aceptada

Respondida
How to use cumsum function?
loadValue = [0;50;20;10;5;30;12;8;20;30;5]; capacity = 300; mat = capacity(1,:) - cumsum(loadValue); for i = 1:numel(l...

casi 4 años hace | 0

| aceptada

Respondida
Random lines confined in a 3d box
figure; axes('XLim', [-0.1, 1.1], 'YLim', [-0.1, 1.1], 'ZLim', [-0.1, 1.1]); hold('on'); view(3) nLine = 100; % A cube has ...

casi 4 años hace | 0

| aceptada

Respondida
How to load portions of .dat file
[fid, msg] = fopen(FileName, 'r', 'b'); assert(fid > 0, msg); while true data = fread(fid, [3, 30000], 'uint32'); if...

casi 4 años hace | 0

Respondida
How to properly call a function from another matlab-file?
zeros(x1, length(tol)) creates a matrix of zeros with x1 rows and length(tol) columns. If x1 is an integer value, this works. Bu...

casi 4 años hace | 2

| aceptada

Respondida
Using diff() or gradient() or other methods to solve the local slope of a set of discrete point?
load x.mat load y.mat slope1 = gradient(y); slope2 = diff(y) ./ diff(x); slope3 = gradient(y, x); % Consider x in the s...

casi 4 años hace | 0

| aceptada

Respondida
Why do I get "Array indices must be positive integers or logical values" error when reading an image?
Did you define "imshow" as a variable? whos imshow which imshow -all To clear it: clear imshow But it is strange, that the ...

casi 4 años hace | 0

Respondida
how to add "drawnow" function in it?
The answer is trivial: simply add a drawnow command at the end of the code. But the question remains, what the purpose is. You ...

casi 4 años hace | 0

Respondida
Compact way to calculate the centroid of a boundary of a set of points
The centroid of the boundary is the mean value of the coordinates: x = rand(40, 1).^2; % More points on the left y = rand(40,...

casi 4 años hace | 2

| aceptada

Enviada


Rotation Matrix
Rotation matrix in 2D, 3D and N-D

casi 4 años hace | 1 descarga |

5.0 / 5

Respondida
Rotate Basis Vectors Programmatically
See: FEX: Rotation Matrix This creates N-dimensional rotation matrices.

casi 4 años hace | 0

| aceptada

Respondida
How to use cumsum function?
CG = 25; C = 0; for i = 1:size(B, 1) if B(i, 5) < 200 if C == 0 C = CG; else C...

casi 4 años hace | 0

Respondida
How to speed up this calculation and remove loop(s)?
There is a very small potential for optimizing in the posted code: for row = 1:size(oFD,1) c1 = oFD.PS(row); c2 = oFD...

casi 4 años hace | 0

| aceptada

Respondida
Access data in cell and save as vector with corresponding variable name
Data = struct(); % [EDITED], was: struct([]); for k = 1:numel(tableCell) C = tableCell{k}; NameList = T.Properties.V...

casi 4 años hace | 0

| aceptada

Respondida
Vertcat error when concatenating images in loop
vertcat(Sro) concatenates Sro with nothing. What is the purpose of this command? Ask Matlab, what the problem is: for i = 1:le...

casi 4 años hace | 0

Respondida
csv file to text file
% [UNTESTED CODE!] function Value = GetCSVElement(File, R, C) % INPUT: File: File name % R: Row index of wanted element. 1 r...

casi 4 años hace | 0

Respondida
loop over variable with different characters
This shows, that you have created a bunch of variables and stored important information in the name of the variables. This desig...

casi 4 años hace | 0

| aceptada

Cargar más