Answered
Replace values in a 3D array, from a condition in a 2D array
% create a 151x432 matrix of random numbers: z = rand(151,432); % make 10000 of the elements 0: z(randi(151*432,1,10000)) = 0...

4 years ago | 1

| accepted

Answered
Sprintf is adding one from categorical data
Try using '%s', rather than '%i' or '%d', in sprintf: c = categorical([1 4 9 16]); sprintf('digit %i, ',c) sprintf('digit %...

4 years ago | 0

| accepted

Answered
Array indices must be positive integers or logical values
Do you have variables called log or logninv? If so, MATLAB will treat, e.g., log(Tb) as taking element(s) at index Tb in the ar...

4 years ago | 0

Answered
Unrecognized function or variable 'boxplotGroup'
boxplotGroup is a function from the File Exchange, so you'd have to download it from there: https://www.mathworks.com/matlabcen...

4 years ago | 1

| accepted

Answered
How do I use the for loop to replace elements in an array?
array = randi(7,1,20); disp(array); % use a for loop to replace all the 4's in array with 19's: for ii = 1:numel(array) ...

4 years ago | 0

Answered
How to randomly present images
% use your folder's path, and use your file type (.png, .jpg, whatever): % img_files = dir(fullfile('C:\Users\ja-woo\Desktop\ha...

4 years ago | 1

| accepted

Answered
Nested loops for double summation
total = 0; for i = 1:10 for j = 5:20 total = total + i + j; end end

4 years ago | 1

Answered
Syntax error for Calcium imaging analyses code: I am trying to implement Ca2+ analyses pipeline but there is a following syntax error:
Define the function like this: function [ROI_intensity1, c, r] = GCamp6(time_interval, timelapse_file, legend_name, neuron_diam...

4 years ago | 1

Answered
how to take an alternating range of elements from a vector to make two new vectors
a = [ 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 ...

4 years ago | 0

| accepted

Answered
how to multiply every element in an array?
o = [3 1 9]; % no for loop: p = prod(o); disp(p); % some for loop: p = 1; for ii = 1:numel(o) p = p*o(ii); end ...

4 years ago | 1

| accepted

Answered
how to solv this issue?
The error happens on this line: temp5=T2(i,5); and is caused by attempting to access an element in column 5 of T2 but T2 has o...

4 years ago | 0

| accepted

Answered
Using Solve function in a for loop
The problem is that solve returns two solutions and you want to store them in a single element of out. Instead of doing that, yo...

4 years ago | 0

| accepted

Answered
Function Handle for a Rectangular Function
% rect = @(t)double(0<=t & t<=1); % returns double array (1/0) rect = @(t)0<=t & t<=1; % returns logical array (true/false) ...

4 years ago | 0

| accepted

Answered
merge three barh (stacked)
Is this what you have in mind? (For each variable A through V, one bar with the sum of columns B - K (always 10 in this file), ...

4 years ago | 1

| accepted

Answered
generate random number between positive and negative and sum of this number is zero
x = randn(); % random number from standard Normal distribution y = -x; % another number such that the sum of x and y is 0 ...

4 years ago | 0

Answered
The problem shows the error of nonconformant arguments or syntax error
I don't get any errors running the code you show, but maybe you mean to use element-wise division ( ./ ) in calculating CD p = ...

4 years ago | 0

Answered
How to make my output display in static box(GUI)
% First, create your static text box somewhere: t = uicontrol('Style','text'); % Later, when you have something to show in i...

4 years ago | 0

Answered
How to plot this equation?
Here's how you might calculate and plot some similar curves. You can take the syntax and apply it to yours. L = 10; x = -1000:...

4 years ago | 0

| accepted

Answered
How can I plot with a for data named h1-h10?
Looks like you might have x1, x2, ..., x10 as well. If not, you can modify this accordingly. h_all = {h1 h2 h3 h4 h5 h6 h7 h8 h...

4 years ago | 0

| accepted

Answered
How to split each element in a cell array into four equal parts?
Use curly braces {} to access the vectors in the individual cells of splitBinaryUserMessage: % userMessage = input('Please inpu...

4 years ago | 0

| accepted

Answered
Warning: The assignment added rows to the table, but did not assign values to all of the table's existing
The warning happens because the table Betas gets a new row added each time the j loop runs its first iteration (except when i i...

4 years ago | 0

| accepted

Answered
Not enough input arguments when they are already defined
Your function theiss calls itself with one input; that's the reason for the error. function [ux] = theiss(r,S,T,t) % theiss ca...

4 years ago | 0

| accepted

Answered
Different variable multiplication for different columns in a MATRIX
A = randi(10,[6 10]) % one way: factor = [2*ones(1,5) 3*ones(1,5)] B = A.*factor % another way: factor = repelem([2 3],1,5)...

4 years ago | 0

Answered
NEED HELP! I'm trying to Create a plot in MATLAB App Designer that uses a variable (for the x-axis) that goes up in real time in seconds....
I'm not sure what the intent is with this line: t= app.StartButtonPushed(); but I suspect that's where the error is ha...

4 years ago | 0

Answered
How do I take the average of elements that are within a range?
A = [320 315 850 325 390 10000 900]; B = []; is_close = abs(A-A.') <= 100; is_counted = false(1,numel(A)); while any(~is_c...

4 years ago | 0

| accepted

Answered
How to read excel data in app designer?
function ButtonPushed(app, event) t = readtable("Kitap1.xlsx","Sheet",1); app.UITable.Data = t; app.UITable.Colum...

4 years ago | 0

| accepted

Answered
How to change x-axis ticks labels in stackedplot?
There does not seem to be an easy way to set the XTick or XTickLabel of a StackedLineChart object (such as what's created by sta...

4 years ago | 1

| accepted

Answered
fonksiyonun bir önceki değerini hafızada tutması
Existing code, for reference: v=10;l=0.1;r=10;i0=0;t0=0;h=0.001; for i=0:1 i1=i0+h*(100*(1-i0)); end fprintf('i1= %f \n',i1...

4 years ago | 0

Answered
Function not giving an output
function y = Parking_Bill(pt,time) % if (pt == (1 || 2) && (size(time) == 4)) if (pt == 1 || pt == 2) && numel(time) == 4 ...

4 years ago | 0

| accepted

Answered
Selecting .tif files from a folder and copy them to another folder
clear all; close all; clc; HOME = '/Users/aahmed78/PhD/Data/SWOT/May2015'; foldername = 'All_tif_images'; foldername = fullfi...

4 years ago | 1

| accepted

Load more