Gelöst


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...

fast 3 Jahre vor

Beantwortet
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 ...

fast 3 Jahre vor | 3

| akzeptiert

Beantwortet
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...

fast 3 Jahre vor | 0

| akzeptiert

Beantwortet
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 ...

fast 3 Jahre vor | 0

| akzeptiert

Gelöst


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...

fast 3 Jahre vor

Gelöst


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...

fast 3 Jahre vor

Gelöst


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...

fast 3 Jahre vor

Gelöst


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...

fast 3 Jahre vor

Gelöst


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]...

fast 3 Jahre vor

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

fast 3 Jahre vor | 0

Beantwortet
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...

fast 3 Jahre vor | 1

| akzeptiert

Gelöst


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 ...

fast 3 Jahre vor

Beantwortet
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...

fast 3 Jahre vor | 1

Beantwortet
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; ...

fast 3 Jahre vor | 0

Beantwortet
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...

fast 3 Jahre vor | 0

| akzeptiert

Beantwortet
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...

fast 3 Jahre vor | 0

| akzeptiert

Beantwortet
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...

fast 3 Jahre vor | 0

| akzeptiert

Beantwortet
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...

fast 3 Jahre vor | 1

| akzeptiert

Beantwortet
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...

fast 3 Jahre vor | 0

| akzeptiert

Beantwortet
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 ...

fast 3 Jahre vor | 0

Beantwortet
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...

fast 3 Jahre vor | 1

| akzeptiert

Beantwortet
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...

fast 3 Jahre vor | 0

Beantwortet
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 ...

fast 3 Jahre vor | 1

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

fast 3 Jahre vor | 0

Beantwortet
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)

fast 3 Jahre vor | 0

| akzeptiert

Beantwortet
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',...

fast 3 Jahre vor | 0

Beantwortet
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)

fast 3 Jahre vor | 1

| akzeptiert

Beantwortet
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...

fast 3 Jahre vor | 1

| akzeptiert

Beantwortet
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...

fast 3 Jahre vor | 0

Mehr laden