Solved


Getting Maximum Chocolate
John loves Chocolate but he didn't have money. The owner of "Sweet Chocolate" launches a scheme for free chocolate. He divided a...

3 years ago

Answered
Summing up subsequent rows if equal
There is another approach you can follow - A = [ 2 3 5 3 4 5 2 3 5 3 4 5 5 6 6 ...

3 years ago | 3

| accepted

Answered
Take the average of predefined consecutive values in a matrix array
A = [1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24]; %Moving mean with 5 element windows, discarding the end...

3 years ago | 0

| accepted

Answered
Inserting 0s in rows of an array
"With this code the 0s are applied only to the first row of A. How come?" In your code, you have already defined rows_B1 to be ...

3 years ago | 0

| accepted

Solved


Implement Euler's formula for calculating polyhedron edges
Your function will take as input the number of faces f and number of vertices v of a polyhedron. It will output the number of ed...

3 years ago

Solved


Kaprekar Steps
6174 is the Kaprekar constant. All natural numbers less than 10,000 (except some with same digits) can be reduced to 6174 in the...

3 years ago

Solved


How many revolutions around the earth
Calculate how many revolutions you will around the earth till 1/1/2100. Given the birhdate find your age in number of days on 1...

3 years ago

Solved


Word with Highest Frequency
Write a MATLAB function that takes in a string and returns the word with the highest frequency in the string. The function shoul...

3 years ago

Solved


Convert row and column subscripts to linear indices
Convert 2D row and column subscripts to linear indices WITHOUT sub2ind Example: row = [1 2 3 1]; col = [2 2 2 3]; sz = [3 3]...

3 years ago

Answered
Estimate the maximum value among three consecutive values in a vector
%Random data for example x = 1:10; y = movmax(x,3,'Endpoints','discard')

3 years ago | 0

Answered
weekday of last day of a month
%Current Month y = 2023; m = 7; %Get the date of the last day of the month day = eomday(y,m) %Get the weekday of the last...

3 years ago | 1

| accepted

Solved


Matrix spiral
Make a spiral in a (n*n) matrix. The spiral has to start in the top left, and has to rotate clockwise to the center. The spiral ...

3 years ago

Answered
speed up the calculation in multidimensional array
You can reduce a for loop by vectorizing the code - load('RP_BIN.mat') load('matlab.mat') [~,c]=size(matrix); xx=find(R...

3 years ago | 1

Answered
Please help to correct my code
You need to use element-wise operators for the variable P_i % Parameters alpha = 0.3; epsilon = 0.4; K_bar = 1; R = 1.05; ...

3 years ago | 0

Answered
Decimation function needs a double precision vector
Using parentheses () on table returns a sub-table. x = primes(20)'; y = (1:numel(x))'; T = table(x,y) %When you use (), Outp...

3 years ago | 0

| accepted

Answered
How to change horizontal alignment of column names in UITable
Use uistyle to add alignment to the uitable - d = {'Male',52,true;'Male',40,true;'Female',25,false}; f = uifigure; uit = uit...

3 years ago | 0

| accepted

Answered
transform a cell into a column vector
load('test.mat') %Vertically concatenate into an array z = vertcat(test{:}) If you want to convert the output into a cell t...

3 years ago | 0

| accepted

Answered
How to add a legend just for one specific point in a heatmap
Try turning the AutoUpdate feature off legend([p1, p2], 'G1', 'G2', 'Location', 'southoutside', 'Orientation', 'horizontal', 'A...

3 years ago | 1

| accepted

Answered
I would like to rotate a circle inside another rotating circle.
Given the current values, you will not obtain the pattern present in the posted image. You will need a bigger core circle to ac...

3 years ago | 0

| accepted

Answered
3d plotting of multiple sets of data
You have total of 49 sets of points, which you can not plot via plot3. The number of inputs, to plot multiple set of data, must ...

3 years ago | 0

Answered
How to select, or filter, the external border/boundary in a set of (x,y)-points?
load("borders.mat"); %Original figure plot(b1(:,1),b1(:,2)) hold on plot(b2(:,1),b2(:,2)) %Obtain coordinates correspondi...

3 years ago | 1

| accepted

Answered
Create a local system of equations function from a set of anonymous functions
Another approach (Note - requires Symbolic Toolbox) equations = {'@(x1,x2) x1.^2+x2-6','@(x1,x2) -2.5.*x1+x2.^2-2'};%Set your e...

3 years ago | 0

Answered
How to plot y-axis limits and y-limitation line
"Is there any additional piece of code I can use to display the actual limits of -220 & 220?" Yes, Ticks, specifically yticks ...

3 years ago | 1

Answered
I' cannot download the trial version of matlab
Visit this webpage to get trial version of MATLAB and Simulink - Trials - MATLAB and Simulink

3 years ago | 0

Answered
I want to collect the smallest arrays on the 3rd axis and get a 2d image.
a=[1 1 1;10 10 10;10 10 10]; b=[20 20 20;2 2 2;20 20 20]; c=[30 30 30;30 30 30;3 3 3]; d=cat(3,a,b,c); out=min(d,[],3)

3 years ago | 0

| accepted

Answered
Automating function creation from an input statement
An efficient approach - %Input, in the form of cell-strings %Note that I have added an extra element eqns = {'x1^2+3*x2+3',...

3 years ago | 0

Answered
How to access element of a matrix using vector function
Use indexing - A=rand(3,10) A(:,3) %First element A(1,3) %First two elements A(1:2,3) %Last two elements A(2:3,3)

3 years ago | 1

| accepted

Answered
What could be possible issue with colon operator here ?
The colon operator in between the call to columns is incorrect. Remove it. allMarks = [24 44 36 18; 52 57 68 38; 66 5...

3 years ago | 1

| accepted

Answered
finding degree and neighbor of each vertex in a subgraph H but indexing according to original graph
The output you get is the index of nodes which are neighbors to the input and not the name of the node. And the input to the fu...

3 years ago | 0

Load more