Réponse apportée
how can i get different answers?
you can write this function function y=myfunction(L,t) a=L(:,1); b=L(:,2); c=L(:,3); y=(a./(b+c))*t; end then call this f...

plus de 4 ans il y a | 0

| A accepté

Réponse apportée
How to split data of a .mat file into trainH trainY testH testY as shown in picture
My guess: 1st step: load your cmc.mat file in Variable A as a struct. 2nd step: extract your 4 variables from struct A. A=loa...

plus de 4 ans il y a | 0

| A accepté

Réponse apportée
How to place values in a matrix with values from another matrix?
Year=[2018;2019;2020;2021;2022]; value1=[13;15;-76;-1;0]; table1=table2array(table(Year,value1)) Year2=[2018;2019;2020;2020;2...

plus de 4 ans il y a | 0

Réponse apportée
Replace zeros with non-zero values from another array
output1=[71;0 ;74 ;75 ;85 ;0 ;88 ]; output2=[39242;32;8385 ;0;17854; 74 ;10499]; output1(output1==0)=output2(output1==0); out...

plus de 4 ans il y a | 0

| A accepté

Réponse apportée
How to search a specific row and a column from a csv file that are associated with the date that was selected?
try this. please follow the dateformat whenever user put the date. I have attached a random csv file. data=readtable('VIX.csv',...

plus de 4 ans il y a | 0

| A accepté

Réponse apportée
Transform table to another format
Headers = ["Fund1";"Fund2";"Fund3"]; Fund1 = [1;0.1;0.2]; Fund2 = [0.3;1;0.4]; Fund3 = [0.5;0.6;1]; correlData = table(Heade...

plus de 4 ans il y a | 1

Réponse apportée
How to compare elements of a 2D array with other elements of the same array.
A=[1 2 3 ; 2 9 5; 4 1 8] [A1 C]=ismember(A(:),A); A2=sort(C); % sorting index A3=A(A2) % value of A those are identical

plus de 4 ans il y a | 0

Réponse apportée
How to apply dec2bin on a string to get a single output?
a = '56515219790691171413109057904011688695424810155802929973526481321309856242040'; a1=cell2mat(split(a,' ')); a2=str2double...

plus de 4 ans il y a | 1

| A accepté

A résolu


Back to basics 8 - Matrix Diagonals
Covering some basic topics I haven't seen elsewhere on Cody. Given an input vector of numbers, output a square array with the...

plus de 4 ans il y a

A résolu


Back to basics 21 - Matrix replicating
Covering some basic topics I haven't seen elsewhere on Cody. Given an input matrix, generate an output matrix that consists o...

plus de 4 ans il y a

A résolu


Find the index of the largest value in any vector X=[4,3,4,5,9,12,0,4.....5]
The given function returns the index of the maximum value in a given matrix. such as X=[4,3,4,5,9,12,0,5] Ans= 6 if maxim...

plus de 4 ans il y a

Réponse apportée
Converting array to column matrix
use colon(:). each variable will be forced to be a column vector col_vector=Eflevel(:) if you want extract first 50 data(50*1)...

plus de 4 ans il y a | 0

| A accepté

A résolu


Sum of odd numbers in a matrix
Find the sum of all the odd numbers in a matrix. Example x = [2 3 5 7 1 4 11] y = 27

plus de 4 ans il y a

Réponse apportée
logical operation on matrix
A=[1 2 3;4 5 6; 4 5 2] B=rem(A,2) % returns the odd number output=A-B

plus de 4 ans il y a | 0

| A accepté

A résolu


Product of Array
Given an array of numbers. Get the product of the array.

plus de 4 ans il y a

A résolu


Remove the Zero
Given an array n, remove all zeros

plus de 4 ans il y a

Réponse apportée
Extract the last day of each month in daily data set
if your data is arranged properly it would be 10227 rows from 1990 to 2017. then try this N=1990:2017; for i=1:length(N) A(i,...

plus de 4 ans il y a | 0

Réponse apportée
Finding rows where the first column values are equal
A=[13453 10359 9955 5257 5299 5258 5849 3644 5848 5397 7230 5396 17132 17130 17118 4767 4768 4770 8291 8292 8316 3191 319...

plus de 4 ans il y a | 1

| A accepté

Réponse apportée
How to create this patterned matrix?
try this: x=[0,8,7,6,5,4,3,2,1]; A1=circshift(x,1); A2=circshift(x,2); A3=circshift(x,3); A4=circshift(x,4); A5=circshift(...

plus de 4 ans il y a | 1

A résolu


Back to basics 22 - Rotate a matrix
Covering some basic topics I haven't seen elsewhere on Cody. Rotate the input matrix 90 degrees counterclockwise (e.g. [1 2; ...

plus de 4 ans il y a

A résolu


Divide by 4
Given the variable x as your input, divide it by four and put the result in y.

plus de 4 ans il y a

A résolu


Max of a Vector
Write a function to return the max of a vector

plus de 4 ans il y a

A résolu


"mirror" matrix
Create n x 2n "mirror" matrix of this type: Examples For n = 2 m = [ 1 2 2 1 1 2 2 1 ] For n = 3 m = ...

plus de 4 ans il y a

A résolu


Insert zeros into vector
Insert zeros after each elements in the vector. Number of zeros is specified as the input parameter. For example: x = [1 ...

plus de 4 ans il y a

A résolu


Rotate a Matrix by 90 degrees
Rotate a Matrix by 90 degrees Example: If the input is: X = 1 2 3 4 5 6 7 8 9 ...

plus de 4 ans il y a

A résolu


Replace Vector Elements
Replace all elements in a vector which are equal to or smaller than zero with 0.1. Example: A = [1 2 3 -1 0 2 -3 -80]; ...

plus de 4 ans il y a

Réponse apportée
Find a word in a text file and read values from that line
A=readtable('example2.txt','delimiter',':'); output=table2array(A(4,2))

plus de 4 ans il y a | 0

Réponse apportée
Summing Certain pattern of elements in vector without using for loop
use reshape function A=[1 2 3 4 5 6 7 8]; output=sum(reshape(A,4,[]),1)

plus de 4 ans il y a | 0

| A accepté

Réponse apportée
How to find the column index of the first nonzero element for every row of a given matrix
you can find your answer here https://www.mathworks.com/matlabcentral/answers/365710-how-to-find-first-1-in-every-row Just fol...

plus de 4 ans il y a | 1

| A accepté

Réponse apportée
How to store the non zero value from each column of a matrix as a column vector (but if there is only zeros on the column store zero) in each iteration?
if there is only 1 zero in a column A=[0.38 0 0 0 0 5 0 0.58 0.71 0 0 5 0 0 5]; idx=A==0; for n=1:size(A,...

plus de 4 ans il y a | 0

Charger plus