Answered
Index in position 2 must be positive or logical value error?
You'd think that 100*round(x,2) would be an exact integer value and in fact would be the same as round(100*x), but that's not ne...

4 years ago | 1

| accepted

Answered
Plot strings on y axis
plot((1:15)/15,[7:-1:0 1:7]) % some plot set(gca(),'YTick',0:7,'YTickLabels',dec2bin(0:7,3)) % set the yticks and labels

4 years ago | 0

Answered
Remove array elements if a certain condition is met with a for loop
Here's one way, using a for loop: JDF = [CorrCKASRoll1,CorrCKASPitch1,CorrJoystickRoll1,CorrJoystickPitch1]; CKASR = JDF(:,1...

4 years ago | 1

| accepted

Answered
Minimalizing a function of two variables
First thing. This: fminsearch(FullScore,[15 0.5]) calls the function FullScore with no inputs; that's why you get that error. ...

4 years ago | 0

| accepted

Answered
Prevent double-clicks in appDesigner
Maybe you can try setting a flag, i.e., a variable of class logical, that indicates whether the data acquisition routine is runn...

4 years ago | 0

| accepted

Answered
Binary enabler for matrix
Inputs = ["AA" "BB" "CC" "DD" "EE" "FF"]; to_enable = logical([1 1 1 0 1 1]); Inputs(to_enable)

4 years ago | 0

| accepted

Answered
How to extract data from matrix A(19,1900) which corresponds to data of Matrix B (1x1900) ?
Pw = randn(19,1900) BSd = randi(19,1,1900) [m,n] = size(Pw); P = Pw(sub2ind([m n],BSd,1:n))

4 years ago | 1

| accepted

Answered
Rearrange the rows as column variables
If I understand correctly, you only need the times corresponding to sensor #0, and the other times can be discarded/ignored. If ...

4 years ago | 0

| accepted

Answered
Assigning the Nth element of Cell Array to another Array
If array is a 1000-by-3 cell array, then you already know how to do it (here I'll use a 10-by-3 cell array): % creating a 10-by...

4 years ago | 0

| accepted

Answered
What is the Colormap for plotting weather radar velocity product with interval?
You can take the colors directly from the colorbar in the image, and use them as your colormap: data = imread('velocity plot.jp...

4 years ago | 0

Answered
Writing a function to count the number of times a word pops up in a random word generation.
Consider the difference between the following two pieces of code. First, set up the variables for both: number_of_words = 5; ...

4 years ago | 0

Answered
How to use 'median filter and gaussian filter' in matlab ?
Try imgaussfilt instead of imgausstfilt (note the extra t) denoise1 = imgaussfilt(randn(100),2); % works denoise1 = imgausst...

4 years ago | 0

| accepted

Answered
How to find variable location?
The way I would go about this is to open "Find Files" https://www.mathworks.com/help/matlab/matlab_env/finding-files-and-folder...

4 years ago | 0

Answered
cannot plot distance with respect to Theta2.
L6 and thta2 are scalars, so you're plotting one point at a time. A line with one point doesn't show up unless it has a marker, ...

4 years ago | 0

Answered
Scatter plot legend for only two of the three plotted categories
scatter creates a single scatter object, so you won't be able to make multiple legend entries from it, but you can create additi...

4 years ago | 1

| accepted

Answered
Issue with for loop, finding file in directory
You mention the file "data_1" in a comment here: https://www.mathworks.com/matlabcentral/answers/1733090-running-4-matlab-scrip...

4 years ago | 0

Answered
extractBefore with matches string
In this case, you can include spaces around '333' to match the pure one: a = {'32563 33308 10314 20227 30113 40117 52008 81531 ...

4 years ago | 0

| accepted

Answered
Plotting filled contours on top of worldmap
I'm not able to see the problem as described, using the data posted. However, check the order of the arguments you're using in ...

4 years ago | 0

| accepted

Answered
Colour coding based on the number of data points in each grid?
You can use nnz to give you the number of points in each bin. Since you already have a logical index idx that tells you whether ...

4 years ago | 1

| accepted

Answered
How to search and find nearest data in the given array
load('array.mat') n = 70; SP = 998.45; % find the rows where column 2 of array is SP matching_rows = find(array(:,2) == ...

4 years ago | 0

| accepted

Answered
Put the leading number corresponding to the number in the column
rowcell={'10302','20245','30108','40112','52013','85911',[],[];'10268',[],'30095','40099','52014','69944','81502',[];'10308','20...

4 years ago | 1

| accepted

Answered
Add vector items one-by-one to array
v = [10 20 30]; a = [11 12 13 14]; out = reshape(a.'+[0 v],1,[])

4 years ago | 1

| accepted

Answered
How to vectorize the following operations?
Yes, this can be vectorized. d = 4; n = 5; A = rand(d,d,n); x = rand(d,n); y = rand(d,n); % for-loop b calculation b_fo...

4 years ago | 0

Answered
overlay two surface or mesh plots
topography = imread('topography.jpg'); curvature = imread('curvature.jpg'); % attempting to crop axes and labels from images...

4 years ago | 0

Answered
Time Vector in X axis Plotting
aa = {rand(482,5) , rand(493,5)}; t = linspace(0, 20,975 ); % Generating Time Vector Series n_aa = cellfun(@(x)size(x,1),aa)...

4 years ago | 0

| accepted

Answered
the piecewise function runs out a weird figure
x=0:0.1:10; y=myfun(x); plot(x,y) function f = myfun(x) idx = x < 1; f = zeros(size(x)); f(idx) = x(idx).^2; f(~idx) = x(...

4 years ago | 0

Answered
Concatenate multiple cell into a single cell
ncell1={'12','21','44','02','35'}; % 1x5 cell ncell2={'03','21','45','45','11'}; % 1x5 cell ncell3={...

4 years ago | 0

| accepted

Answered
My variable names for a table aren't the same length even though they are both 20 long and won't change
I don't know what class app.UITable3.Data is, but in another question (here), you say that calling writematrix(app.UITable.Data)...

4 years ago | 0

| accepted

Answered
I want to color code US states by specific metrics. What is the easiest way to do this?
Here's how you can make a map colored by log10 of Population Density (2000), which is the variable color_value below. You can ch...

4 years ago | 1

| accepted

Answered
how to compare two values that are repeated in two vectors?
A = [10 56 34 11 34 ]; B = [10 56 34 11 ]; result = [B.' sum(A==B.',2)<=1] Breaking that expression down: A==B.' % compare...

4 years ago | 0

| accepted

Load more