Answered
Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
Use the debugger to find the cause of the problem. Type e.g. this in the command window: dbstop if error Run the code again. W...

7 years ago | 0

| accepted

Answered
Matlab should have give array but it gives a number. How to fix?
Use the elementwise division: d1i=(2*R.*lambda) ./ (10.^(-2).*r1i); % ^ You have used the elementwise operat...

7 years ago | 0

| accepted

Answered
Overwritting problem in for loop
nExisting = numel(dir(fullfile(folder, 'Grain #*.jpg'))); for i = 1:k f = sprintf('Select a ROI and double click to crop #%d...

7 years ago | 0

| accepted

Answered
unable to upload files in file exchange
The problem exists for at least 2 weeks now, see https://mathworks.com/matlabcentral/answers/447952-update-of-fileexchange-submi...

7 years ago | 0

Answered
Shifting position of an element in a vector from 1st to last
Or: X = [(1:N-1) + triu(ones(N, N-1)), (1:N).'] % Auto-expanding: >= R2016b This is 2 times faster for N=200, and 3 times for...

7 years ago | 1

Answered
Command Window to GUI figure
See: FEX: CmdWinTool Key = '== Start logging:' fprintf('%s\n', Key); ... yourCode Final = strsplit(CmdWinTool('getText'), ch...

7 years ago | 0

| accepted

Answered
intermittant imwrite permissions error
Maybe your disk is full or a callback of a GUI or timer changed the current directory. Let Matlab help you to identify the probl...

7 years ago | 0

Answered
HELP- MATLAB FREEZING/ NOT OUTPUTTING CODE
It will increase your code, if you clean it up: Look at the orange marks in the editor, which show you, that etaotto have been d...

7 years ago | 0

Answered
Preserve nonwhite background when using copy figure on macOS
Did you consider this already? https://www.mathworks.com/help/matlab/creating_plots/copy-figure-to-clipboard-from-edit-menu.htm...

7 years ago | 0

Answered
Convert image to a c++ header file
Maybe this helps - smarter without a loop: function export_Img_2_Header( img, filename ) % EXPORT_IMG_2_HEADER Create C++ hea...

7 years ago | 0

Answered
Matrix full of 0 when using poly2mask
The documentation (please read it: doc poly2mask (link)) sounds, like xi and yi must be in the range of 1:m and 1:n. This works ...

7 years ago | 1

Answered
Trying to generate a value each loop, and then add that value to multiple variables in an array
Your code contains several problems: for i = 1:100 i= i+1; end You do not have to increase the loop counter manually in...

7 years ago | 1

| accepted

Answered
matlab 2018b trial version for 32bit
There is no 32 bit version of Matlab R2018b. The last 32 bit version was R2015b.

7 years ago | 1

| accepted

Answered
How to solve ODEs with time dependent parameters by RK4 method?
A simpler version without nested and anonymous functions: function main % To get the temperature by interpolation: t_in = [...

7 years ago | 1

| accepted

Answered
getting rid of decimals in matlab
There is no difference in the value between 2.4 and 2.40000. This is a question of the display only. So it depends, where you di...

7 years ago | 0

Answered
How to add a specific value with arrow or a marker in the axis of a plot?
x = rand(1, 10); m = mean(x); axes('XLim', [1, 10], 'NextPlot', 'add', 'Box', 'on'); plot(x, 'b'); yline(m, 'g'); text(10...

7 years ago | 0

| accepted

Answered
Change the aspect ratio of x,y to plot Longitude and Latitude correctly ( I have the conversion needed- need help implementing it)
Do you want to set the DataAspectRatio of the axes? https://www.mathworks.com/help/matlab/ref/daspect.html

7 years ago | 0

| accepted

Answered
How to share plot from one GUI to another using setappdata / getappdata approach?
To avoid troubles, define the Parent property when drawing in a GUI: ... Ax = handles.axes1; plot(Ax, x1,y1,'b','LineWidth',2...

7 years ago | 0

Answered
How to parse (extract) data from a text file?
Str = fileread(FileName); CStr = strsplit(Str, char(10)); match = contains(CStr, 'CANFD'); Data = CStr(match); Data cont...

7 years ago | 0

Answered
Straight line from all points of A to every single point of B
With some guessing: nB = size(B, 1) nA = size(A, 1) STR = -20:.01:20; n = numel(STR); C = cell(1, nA * nB); iC = 0...

7 years ago | 2

| accepted

Answered
PROBLEM: How can I update only the changed variables in my saved workspace?
This would be much easier when you use functions and separate workspaces. Running a bunch of scripts and collecting data in the ...

7 years ago | 0

Answered
Some extra and useless lines around GUI!
This looks the ticks of an axes object, which fills the complete figure. Either remove this axes object, if you do not need it, ...

7 years ago | 0

| accepted

Answered
Index exceeds the number of array elements .
Simplify your code: ii = 4 * (i-1) + 1; dy(ii) = r * y(ii) * (1 - (y(ii) + y(ii+1)) / K) - d * y(ii+2) * y(ii); Now use t...

7 years ago | 0

Answered
How to unnest cell arrays using a for loop?
A = [{{{{4}}}}, {0}, {{1}}, {{{0}}}] B = zeros(size(A)); for iA = 1:numel(A) a = A{iA}; while iscell(a) a =...

7 years ago | 3

| accepted

Answered
Runge-Kutta solving 2nd ODE
ODE integrators work with functions of 1st order only. If you have an equation of 2nd order, you can convert it easily to a syst...

7 years ago | 0

Answered
C-order reshape of multi-dimensional array in matlab
Reshaping in line-wise order is not meaningful, because reshaping means to keep the order of elements in the memory and the orde...

7 years ago | 2

| accepted

Answered
Help needed to validate if a directory exists and the user has write permissions
What about this: function Folder = ChooseWritableFolder(Base) ready = false; while ~ready Folder = uigetdir(Base, 'Selec...

7 years ago | 2

| accepted

Answered
need help writing the code to these equation using ode45
Remove the line "ydot = @(t, y)[y(2); y(3); ...", because it is not useful here. The function is called with teh inputs t,y, not...

7 years ago | 1

| accepted

Answered
Matlab doesn't run on my laptop
Sometimes the preferences are damaged and prevent Matlab from starting. Try to rename the corresponding folder, e.g. 'C:\Use...

7 years ago | 0

Answered
general code for sorting inside cell
ref = 69; A = {[1,2,3,12],[19,34,37,15,33,35,36],[19,20,21,22,23,5,8,11,13,15,17], ... [37,38,65,40,42,49,66],[5,11,3...

7 years ago | 0

| accepted

Load more