Answered
For looping/if statement issue (simple hopefully)
There are a few problems. Problem 1: for c = i tells the loop to iterate once, with the value of c being i. I imagine you mea...

10 days ago | 0

Answered
How to find the index of the first repeating value.
a = [1,2,3,4,5,6,7,8,8,8,8,8,8,8,8,8,8,8,8]; b = linspace(0, 10, length(a)); % plot(a,b) plot(b,a) idx = find(diff(a) ==...

10 days ago | 0

| accepted

Answered
How do I save the output from a for loop to an array?
d = zeros(a,1); for c = 1:a d(c) = input(['Enter the number of lines in loop ', num2str(c),': ']); end

10 days ago | 0

Answered
asking for suggestion to modify a form of result
Is this what you mean? clc clear all close all k=12; m=40; v=k/m; a= 24:1:120; b= 24:1:120; c=24:1:120; d=24:1:120;...

11 days ago | 0

Answered
Drag and drop plot (inset) within another plot?
Try setting 'HitTest','off' for whatever objects you add to the axes. This will allow mouse clicks to pass through to the axes u...

11 days ago | 0

| accepted

Answered
why do I get "Array indices must be positive integers or logical values" for my coding
Look at what you get with str2double on a character vector expressing a function: g = '@(x)sin(x)'; f = str2double(g) Instead...

11 days ago | 0

Answered
How can i manage a wrong input, whitout restart the my script ?
Generally, for this method of gathering user input, you would use a while loop that iterates until the input is valid. Somethin...

11 days ago | 2

| accepted

Answered
Create cell array of column indices of a specific string
% make cell array g g = repmat({repmat({''},40,50)},5,1); % put 7 random 'Latitude's in each cell for ii = 1:5 g{ii}(ran...

11 days ago | 1

| accepted

Answered
I want to replace NaN occurring between two numbers with an average of the two numbers, however, I do not want to touch places where NaNs are continues. poro.mat attached.
load('poro.mat') idx = 1+strfind(isnan(poro.'),[0 1 0]); poro(idx) = (poro(idx-1)+poro(idx+1))/2; disp(poro(idx.'+[-1 0 1...

11 days ago | 0

| accepted

Answered
How to save table (or cell) as file with custom extension?
"writetable (and writecell) do not allow saving with a .in extension." Yes they do, but you must explicitly specify the FileTyp...

11 days ago | 0

| accepted

Answered
How to obtain a matrix from the iterations of a for loop?
Use kron. A=[ 0.2167 0.2467 0.2520 0.2652 0.2661 0.2907 0.3498 0.4211 0.5348 0.5735 0.5242 0.4...

11 days ago | 1

| accepted

Answered
Checking if columns of matrix are equal to some array
Don't return yet, when you find that some particular column of data is not equal to template. You still need to keep checking th...

11 days ago | 2

| accepted

Answered
Reverse filling a array in MATLAB
array_1 = [NaN,NaN,NaN,NaN,NaN,340,133,133,133,NaN,NaN,NaN,145,NaN,NaN,NaN,NaN,78,68,89,NaN,NaN,NaN] array_1 = fillmissing(arra...

12 days ago | 0

| accepted

Answered
If statement working partially
Part of the problem might be the usage of || and &&. In MATLAB, && takes precedence over ||, so an expression like this: x == ...

12 days ago | 1

Answered
Grouping the Elements of the Array
% Taking your example of an array with 17 elements (rather than 897880), data = 1:17; % and you want to group them into groups...

12 days ago | 0

| accepted

Answered
Create Header with write matrix function
Random data and titles: MTR_data = rand(144,4); MTR_titles = {'Put' 'Your' 'Titles' 'Here'}; You can make the data into a cel...

12 days ago | 0

| accepted

Answered
How to remove certain elements in a matrix according to the value of elements in an array
A = [ 5 6 2 1 4 2 7 9 9 5 ] idx = A(:,1) < 5; A(idx,:) = []

12 days ago | 0

| accepted

Answered
How can I get matlab to go through the list "time" and give all the indexes that are between my upper and lower range for "times"
Try this: [time_idx,times_idx] = find(time > lowrange.' & time < upperrange.') % % ^^^^ ...

13 days ago | 0

| accepted

Answered
Finding the maximum two values within one field conditioned on the values in another field
% random data feedback = struct('gains',num2cell(rand(1,8))); disp([feedback.gains]); %separately save gains from Condition A...

13 days ago | 0

| accepted

Answered
recur.m function
This syntax: function y = recur(a,b,n,x,x0,y0); defines the function recur. If you have already defined the function in an m-f...

14 days ago | 0

Answered
Hi i have a problem i got this error while making program which detect face mask Index in position 1 exceeds array bounds. Error in maskdetection (line 21) rectangle('Pos
Instead of looping over rows of BB and trying to access the corresponding row in NB and MB each time (which may or may not exist...

14 days ago | 0

| accepted

Answered
Specify Square Marker in a Plot
You can break it up into multiple lines: X = (1:25); Y = [2 1 2 2 2 3 1 4 3 2 1 2 3 7 11 8 5 2 3 4 5 8 5 5 7]; fig1 = figure(...

14 days ago | 1

| accepted

Answered
cell arrays not explicited
Here's a table T that matches the screen shot: Dtc = {'P0C43';'P0532';'P1C68'}; Lamp = {'3 trip MIL';'3 trip MIL';'1 trip Wren...

14 days ago | 0

Answered
how to sum cell elements in a dynamic cell table
Is this similar to what you want to do? (Using 5 columns here instead of 16, and using 3 rows.) data = (1:5).*[1;7;20] [L,M] =...

14 days ago | 0

Answered
how to batch save and load loop variable
How about making a a matrix? a = zeros(3,10); for i = 1:3 a(i,:) = rand(1,10); end disp(a); Or, if each iteration prod...

14 days ago | 0

Answered
use of "if" and "elseif" in regionprops
Index score by cnt inside the loop, and don't use the same variable score for the numeric score and the label (#3, #4, etc.) you...

14 days ago | 0

| accepted

Answered
How to generate a 2D meshgrid based on the coordinates (longitude and latitude) of points
xy = [1 3; 2 9; 6 6; 8 8; 9 1]; % [xx,yy] = meshgrid(sort(xy(:,1)),sort(xy(:,2))) % note: maybe you want to sort x and y firs...

14 days ago | 1

| accepted

Answered
Replacing whole row with NaN's if first value is equal to 13 or 15.
Do you mean the value of the first column is equal to 13 or 15? A = randi(20,10,5) idx = A(:,1) == 13 | A(:,1) == 15; A(idx,:...

14 days ago | 0

| accepted

Answered
how to slice a 3d array with slider?
Here's one way to do that: clear all clc y = randn(10,10,10); N = size(y,3); h = uicontrol( ... 'style','slider', ...

14 days ago | 0

| accepted

Answered
How to save function as f.m?
Are you able to click "Save As..." and then, in the Save dialog window that pops up, change the "Files of Type:" from .mlx to .m...

14 days ago | 0

Load more