Answered
vectorizing or speeding looped code
This should help, though I've already made assumptions about the sizes of arrays. How many rows/columns are in each variable? X...

5 years ago | 0

Answered
Efficiently calculating sum-thresholds across vector
You could do the following but with the caveat that it assumes samples are all positive values runningSum = cumsum(samples); i...

5 years ago | 0

| accepted

Answered
how to use an if statement to determine whether an index is out of bounds
If indices is outside of bounds, I want to display ''Error: index is out of bounds.' The conditional expression in your if bloc...

5 years ago | 0

Answered
How can I create different colors in the plotted chart for a lot of data
I'm coming at this from a slightly different angle. You can interactively highlight different lines by setting up a slider in th...

5 years ago | 1

| accepted

Answered
how to get character from an array using another logical array?
A slight modification on your inputs: V = ['1b.%291x g'; 'yig&aaSgwa'; 'tqtbbs!?R!']; logicalVec = logical([ 1 0 1 0 1 0 1 ...

5 years ago | 0

| accepted

Answered
How to find the most frequently repeated time interval?
First I read in data as a string array opts = detectImportOptions(filename,'TextType','string'); opts.SelectedVariableNames = ...

5 years ago | 1

| accepted

Answered
How to find a corresponding matrix value
You can get the corresponding values in W as follows [mQ,idx] = max(Q,[],2,'linear') W(idx)

5 years ago | 1

| accepted

Question


Issue with browser slowing down while using MATLAB answers
While writing/editing answers on the forum, I've been having issues where the tab in my google chrome browser that's in use beco...

5 years ago | 1 answer | 0

1

answer

Answered
How to select different colors and legend for the bar plot??
For the first part of your question, you can do so as follows: x = rand(3,2); h = bar (x); h(1).FaceColor = 'red' h(2).FaceC...

5 years ago | 1

| accepted

Answered
averaging the matrix and creating an averaged matrix
As far as I understand you want the average of each 5 rows by 10 columns hence the expected output size of 53x101. You can do th...

5 years ago | 0

Answered
snapshot problem in video processing
snapshot() is intended for use with a cameraboard object or webcam object and you are attempting you input an image object. You...

5 years ago | 0

Answered
How to graph data in cells?
Your data has an empty cell in it so the first step here is to remove that ToBeGraphed(cellfun(@isempty,ToBeGraphed))=[]; % rem...

5 years ago | 0

| accepted

Answered
Extract subset of time-curves from a 4D volume
I can reduce this to a single for loop which iterates through the timesteps but i'm not sure about doing this entirely without l...

5 years ago | 0

| accepted

Answered
Sum of elements in an array over x
a = [0.023 0.056 0.053 0.034 0.021 0.075 0.088]; result = sum(a(a>0.05))

5 years ago | 1

| accepted

Answered
Building a matrix inside a for loop
You could do it as follows: xlsData = xlsread('PartS_all.xlsx'); partID = xlsData(:,4); uPartID = unique(partID).'; % Unique ...

5 years ago | 0

| accepted

Answered
how to store coordinate values xy[] for randomly generate point
The format you used (based on the code you provided) is a structure and the format you are looking for is an array. To generate ...

5 years ago | 0

Answered
Multiple combinations of a matrix
Try the following, it should work for any size of M. function x = pairCombos(M) numRows = size(M,1); C = combnk(1:numRows,2...

5 years ago | 0

| accepted

Answered
How to reshape in 3D a downsampled matrix
Easiest thing to do would be just this: newData = data(1:factor:end,1:factor:end,1:factor:end);

5 years ago | 0

| accepted

Answered
Using a for loop to graph values using different colors
If you want to use scatter so that the color depends on distance, this is how you do it: % Data clear all close all data = [...

5 years ago | 1

Answered
Finding Minimum Distance Between Points to Find Indexed Variable
If you don't have the statistics and machine learning toolbox you can do the following: [~,idx] = min(abs(dtamatrix(:,2) - Feli...

5 years ago | 0

| accepted

Answered
Create multiple arrays with different names and specific data
It is possible to do exactly what you asked but that is considered a bad coding practice (explanation here). Why don't you st...

5 years ago | 0

| accepted

Answered
Creation of an automatic polyline
It looks like you have a binary image but you uploaded it as a .jpeg, I have included 3 lines to "workaround" and get back to an...

5 years ago | 0

| accepted

Answered
How to crop a circle from an image?
Try the following tutorial: % Setup clear close all clc inputImg = imread('cameraman.tif'); % Show demo Image hf = figu...

5 years ago | 0

| accepted

Answered
calculating area and perimeter for pap-smear image
There are numerous ways you could segment the nucleus, I elected here to threshold based on R,G,B values in the image. To work o...

5 years ago | 0

| accepted

Answered
I want to extract values from second column of the matrix which correspond to the range 6 to 7 of the first column. How to do it?
Let's say your matrix is called M, then you can extract rows from column 2 corresponding to those in column 1 which are between ...

5 years ago | 1

| accepted

Answered
3-D matrix operations
Here's the method I was suggesting. The idea is to take the first value and add half the difference (effectively interpolating) ...

5 years ago | 0

Answered
Read text file with string
You could use the readmatrix function as follows: filename = 'My2.TXK' opts = detectImportOptions(filename,'FileType','text') ...

5 years ago | 0

| accepted

Answered
Extract data (timestamps) from csv file
You could read the file in as a character vector with fileread and then use regexp as follows: filetext = fileread('Info.csv');...

5 years ago | 0

| accepted

Answered
How to Interpolated data outliers
Generate some sample data: C = (1:3630).'; idxout = randperm(3630,500); % random index for outliers C(idxout) = C(idxout)+200...

5 years ago | 1

| accepted

Answered
matlab code How to dived 400*500 image into 40*50 and calculate object area in each block. put all blocks in one imafe
You can find out which blocks are crops (according to your definitions) as follows: B = blockproc(Img, [40 50], @(block_struct)...

5 years ago | 0

Load more