Answered
Why am I getting the error "Array indices must be positive integers or logical values"?
for i = 2:n for j = n:-1:1 f(j) = ((f(j)-f(j-1))/(x(j)-x(j-(i+1)))); end end looks like when j is 1, you h...

6 years ago | 0

| accepted

Answered
Select certain percentage of a plot
x = [ 0 1 2 3 4 5 6 7 8 10 11 12 13 14 15 16 17 18 19 20]; y = [0 1 3 1 2 0 0 0 2 1 2 2 4 5 6 7 8 9 11 20]; percent = .1; th...

6 years ago | 0

| accepted

Answered
Filling an array with indices without loops/if-statements
if T is your table with rows of planets, and columns of rad, orb, and temp, you can use logical indexing: % % rad > 0.4 && rad ...

6 years ago | 0

Answered
Recording values from a loop
You're missing indexing for your T while %Calculations for z=1:beds; temps(z)=T(z); end %Misc code beds=beds+1; ...

6 years ago | 0

Answered
How to prevent uitab from printing UserData
Under 'User Data' in the documentation for uitab, it actually states: Note Do not use this property in apps you create with Ap...

6 years ago | 1

| accepted

Answered
How to check and unchecked box using plot in GUI
"How can i unchecked this plot " axes(handles.axes1) plot2 = plot(xx,yy,'m'); hold on xlevel('Hours (hr)'); ylevel('Corr. ...

6 years ago | 0

| accepted

Answered
Simulation results on command window
What you can do is calculate the average outside of the loop, for example, for snrm: for i=1:Nrep Inp=randn(1,Nrep)*SD+Ip;...

6 years ago | 0

| accepted

Answered
How to copy only the output of a function and paste the output in another function?
function y1 = func1(x) y1 = x^2 end function y2 = func2(x) y2 = x+10 end y2 = func2(func1(2)) % if x=2

6 years ago | 0

Answered
How do I find the probability that 0 would be selected if a random number was selected?
Just do: d = [1, 0.5, 0.01, 0.5, 0, 1, 2, 15.31, 33, 12, 3, 7, 2, 15, 38, 0, ... 2.5, 0, 0.4, 17.8, 0.5, 10.6, 0, 0.1, 11,...

6 years ago | 0

Answered
Plot in increments of 30 seconds
if you want to plot every 30-second segment as its own line object: segment = reshape(1:120,30,4); for i = 1:size(segment,2)...

6 years ago | 0

Answered
Using loop to solve a summation
No, you need to increment m with each step and add each partial sum. This is what you need: x= 0 for m = 0:1200 x = x + ...

6 years ago | 0

Answered
How do I write an if statement that says a variable is a error given a condition?
%%outside forloop errCnt = 0; %% inside forloop if X=1.2||Y=0 && U1>U2 %How do I write that Y is an error if the abo...

6 years ago | 0

| accepted

Question


Convert folder of functions - > Class folder
I have a folder full of functions and I would like to turn it into a class folder. example: my folder of function has func1.m ...

6 years ago | 1 answer | 0

1

answer

Answered
Saving matlab results many times using loop
just do: my_filenames = {'file1','file2','file3'} for i = 1:length(my_filenames) save(my_filenames{i},'someVariable') e...

6 years ago | 0

Answered
I'm not sure what I'm doing wrong that gives me a error
your time vector and velocities are not the same length.. I'm guessing you're incrementing by 10. you're also missing some ele...

6 years ago | 0

Answered
Graph won't display
you need to do element wise operations with a period before: x = linspace(0,10,100) y = x.^2 ./ (pi.*(1-x)) plot(x,y)

6 years ago | 0

| accepted

Answered
How to fill a zeros matrix with text?
Your syntax for your for loop is incorrect, I think you mean to say: for i = 1:12 for j = 1:12 %etc etc end...

6 years ago | 0

Answered
How To make matlab rerun the program?
Use a while loop to keep re-running your function or script while some condition is true (in this case, 'not met'): https://www...

6 years ago | 0

Answered
i do not have a licens to use it
You will need to buy it. Just press 'products' at the top of their website. But there's also a free trial: https://www.mathwor...

6 years ago | 1

Answered
Variable change with time interval
you can use if/else statements example: if and(t >= 0, t < 900) x=1; elseif and(t>= 900, t<1800) ...

6 years ago | 0

| accepted

Answered
can anyone tell me what y really means here? [y,Fs] = audioread(filename)
https://www.mathworks.com/help/matlab/ref/audioread.html Towards the bottom: 'Audio data in the file, returned as an m-by-n ...

6 years ago | 1

Answered
Legend colors do not match plot colors.
You can also shorten your code: c01 = [0.2422 0.1504 0.6603]; c02 = [0.2803 0.2782 0.9221]; c03 = [0.2440 0.4358 0.9988]; c0...

6 years ago | 0

| accepted

Answered
How can I set different colors for different lines in a plot?
Example: a = line(x,y) % a is the handle to my line object a.Color = [1 0 0] %red %or you can do: set(a,'Color',[1 0 0])

6 years ago | 1

Answered
What is this error I get?
do you mean to do g(1:nrow,1:ncol) = g(3:nrow-2,3:ncol-2);

6 years ago | 0

Answered
Running correlations between two matrices
Have you tried adding another forloop for the columns? for i=1:982 for j = 1:10000 z(i,1)=corr(A(i:i+59,j),B(i:i+59,j...

6 years ago | 0

| accepted

Answered
Plotting specified columns using plot function
plot(A(:,3),A(:,[25 27 30 32 35]))

6 years ago | 0

| accepted

Answered
GUI PIANO SIN /SAWTOOTH/SQUARE
perhaps you can create a listbox on your main script and assign it a tag 'lb1' so that you can point to it elsewhere lb = uicon...

6 years ago | 0

Answered
Error dividing polynomials in plot
x3 = linspace(3,10,100); y = (2.*x3+1)./((3.*x3-1).^(1/3)); plot(x3,y)

6 years ago | 0

| accepted

Answered
searching an array for a value embedded in a string
search = 'Pan Scale'; a = C{contains(C,search)} % if C is your cell array, locate index and access cell. exp = '\d*'; %all con...

6 years ago | 0

| accepted

Answered
Getting the Incorrect Plot
x = -10:.1:8; func = (x-6).*((x.^2)-1).*(x+8); plot(x,func); title("Graph of Function"); xlabel("Vector Values"); ylabel("F...

6 years ago | 0

| accepted

Load more