Answered
Using 'OR' operator with 'case' statement
This would be the proper way for using or: switch value case {1,2,3} % execute this case {4,5,6} % execute this end

6 years ago | 11

| accepted

Answered
Returning indicies from a matrix and returning the indicies not included in the first answer
allVisibleVolcanos = [3 7 8 9 50 ...

6 years ago | 0

| accepted

Answered
How do i make the title, axes labels, and legends larger in existing figures?
each one of those graphic objects (title,axes,legend) has their own properties you can edit. for example, if you havent assigne...

6 years ago | 0

Answered
Sum variables from three in three, after summing compute an equation and organize all data into a new column?
https://www.mathworks.com/help/matlab/ref/sum.html

6 years ago | 0

Answered
How do I make function which gets as input arguments matrix of chars work?
Use curly brackets. example: case {'GUU', 'GUC', 'GUA', 'GUG'} aminoacids{m} = 'Val'; I also dont think you need ...

6 years ago | 1

Answered
using strcmp on nested cell array (cell array within a cell array)
if a is your cell array: myText ='Text1'; idx = find(cellfun(@ischar,a)) %returns those indices where cell is a chr array idx...

6 years ago | 0

Answered
Multiple Plots on Single Figures in Loop
figure() will automatically create a new figure. figure (1) %Plot vehicle speed trace figure('Name', 'Vehicle Speed','Number...

6 years ago | 0

Answered
How can I create a structure?
Remove the quotation marks. You're storing the string 'Columns' and 'Rows' isntead of the actual numeric variable. You also don...

6 years ago | 0

Answered
Is there a faster alternative to plot in MATLAB?
im not too sure how the rest of your code looks like, but maybe you can clean it up by just assigning handles to your axes (each...

6 years ago | 0

Answered
write a script that creates identity matrices of any size without using the function eye
n = zeros(5); %square matrix for i= 1:size(n,1) n(i,i) = 1; end

6 years ago | 0

Answered
implement a script that calculates 1^3+2^3+...+10^3+11^3. a) use a for or a while loop. b)use vectors
x = 1:11; %for loop sum=0; for i = 1:numel(x) sum = sum + x(i)^3; end %vector method vec = sum(x.^3);

6 years ago | 0

| accepted

Answered
switch statements and trig function
you can just run the input once, and evaluate the input as a whole. word = input('enter letter followed by number','s'); if n...

6 years ago | 0

Answered
using while loops and random number generators
you needed one more line: var = 'y'; while (var=='y') u=input('how many?', 's'); u = str2num(u); % u was a char, no...

6 years ago | 0

| accepted

Answered
Dropping NaN observations from Matrix
if you had a matrix A and wanted to search for NaNs in each row nanRows =[]; for i = 1:size(A,1) if any(isnan(A(i,:))) % ...

6 years ago | 0

Answered
How can I animate plotted data over time?
each update of the plot can be shown with drawnow https://www.mathworks.com/help/matlab/ref/drawnow.html

6 years ago | 0

| accepted

Answered
Graph plot always appears as a straight line
if r is a constant, you will get a straight line. if r varies, then you will get a curve. also, you may want to add a period be...

6 years ago | 0

Answered
Multiplications inside a cell array
use cell brackets to access contents of the cell array. so if c is your 4x12 cell array, then c{2,1} would retun the array insi...

6 years ago | 1

| accepted

Answered
How can i detect max value and his index ?
[max_val idx] = max(a) max_val would be the max value in your array a, idx would be the index. i have no idea what 'a(1)=...

6 years ago | 0

Answered
GUI - Real time Spectrogram
I am not too sure what you have tried so far, but reading this documentation might help with both your planning of how you want ...

6 years ago | 0

| accepted

Answered
Sort elements of an array with a given a priority, keeping track of indexes (includes repeated elements)
There might be something more elegant than my for-loop, but this should work. Let me know! vR = [1.5 2 1.25 3 3.5 5 8 2.359 3 ]...

6 years ago | 0

Answered
Using loop to plot numbers on a single plot while simultaneously giving each number/data point a different marker symbol.
You need to do, for i = 1:12 plot(z(i),'Marker',markers{i}) hold on end

6 years ago | 0

| accepted

Answered
How to create a vector?
v = []; for k=2:length(val)-1; if(val(k)>val(k-1)&val(k)>val(k+1)&val(k)>1) k disp('Prominant peak found...

6 years ago | 0

| accepted

Answered
Find average values in a table
a = randi(10,5,7); % let a be your matrix closest_all =zeros(1,7); for i = 1:size(a,2) %first row values, num = a(1,i); ...

6 years ago | 0

| accepted

Answered
Unable to perform assignment because the left and right sides have a different number of elements.
you are setting an element, a(t) to be equal to your entire matrix a. Not sure what you are trying to do, please reformat you...

6 years ago | 0

| accepted

Answered
How to go from if..end to switch..end?
Not sure what you are doing with your loop, but according to what you have, switching from if/else to switch/case: soma=0 fo...

6 years ago | 1

Answered
Identifying a file based on character
example use of the contains() function: my_string = '001BL100XP0102.HWR' if contains(my_string,'P01') targ_coord = [...

6 years ago | 0

| accepted

Answered
I have to create a matrix using only zeros, ones and eye
your command A = [B;C] concatenated them vertically. Try: C = eye(5) C(1,:) = 1; % turns every element along the first row to...

6 years ago | 0

| accepted

Answered
How to find the difference of the maximum points between datasets
if y1 is vector consisting of the y-values for your sinewave, max(y1) will return the max value. min(y1) will give you its mi...

6 years ago | 0

Answered
Creating a matrix which has particular order of element ?
Can you be more clear in what you are trying to do? Is this pattern supposed to go on? Or is this matrix A that you have provide...

6 years ago | 0

Answered
Data point in plot connecting randomly to each other
I would sort the x values and sort the y values based on how the x values were sorted. You can do this with [sorted_array sor...

6 years ago | 1

| accepted

Load more