Risposto

Code explanation (bw)

The (:) reshapes a matrix into a column vector. imageOutR = [zeros(1,3); 2 5 13; 0 1 2; 1 3 5] % 4x4 matrix for instance bw2 =...

Code explanation (bw)

The (:) reshapes a matrix into a column vector. imageOutR = [zeros(1,3); 2 5 13; 0 1 2; 1 3 5] % 4x4 matrix for instance bw2 =...

oltre 2 anni fa | 0

Risposto

double2str and bin2str

Doing help bin2str % and help double2str did not show any results from which I assume there are no such functions. Use num2s...

double2str and bin2str

Doing help bin2str % and help double2str did not show any results from which I assume there are no such functions. Use num2s...

oltre 2 anni fa | 0

Risposto

How to multiply 2 arrays by elements

A = [3-4j, 1+3j, 10+10j]; B = [4+5j, 2+1j, 0+0j]; A.*B

How to multiply 2 arrays by elements

A = [3-4j, 1+3j, 10+10j]; B = [4+5j, 2+1j, 0+0j]; A.*B

oltre 2 anni fa | 0

| accettato

Risposto

Why doesn't my code recognize the input function in the loop?

try this ctr = 0; for i = 1:1:3 numbers = input('Enter a number: '); if numbers ~= 0 ctr = ctr + 1; el...

Why doesn't my code recognize the input function in the loop?

try this ctr = 0; for i = 1:1:3 numbers = input('Enter a number: '); if numbers ~= 0 ctr = ctr + 1; el...

oltre 2 anni fa | 0

Risposto

How to remove rows from structure based on value condition of field?

S.A = [1 2 3 4 5 6; 11 12 13 14 15 16; 21 22 23 24 25 26; 31 32 1 34 35 36]; S.B = ceil(50*rand(2,2)); S.C = "Some string"; S...

How to remove rows from structure based on value condition of field?

S.A = [1 2 3 4 5 6; 11 12 13 14 15 16; 21 22 23 24 25 26; 31 32 1 34 35 36]; S.B = ceil(50*rand(2,2)); S.C = "Some string"; S...

oltre 2 anni fa | 0

Risposto

how to use the output of a user defined function as the input of another user defined function?

num = 1:10; [S] = Addition(num) [M] = multiply(S) % pass output of function 1 as input to function 2 % function 1 function...

how to use the output of a user defined function as the input of another user defined function?

num = 1:10; [S] = Addition(num) [M] = multiply(S) % pass output of function 1 as input to function 2 % function 1 function...

oltre 2 anni fa | 0

Risposto

How to delete all rows of a matrix wherever any value is invalid (999)?

M = [99 1 25 999; 10 1 2 6; 14 99 25 65; 99 1 2 9; 9 1 999 10] [row1,~] = find(M(:,1) == 99) % search for 99 in col1 [row2,~] ...

How to delete all rows of a matrix wherever any value is invalid (999)?

M = [99 1 25 999; 10 1 2 6; 14 99 25 65; 99 1 2 9; 9 1 999 10] [row1,~] = find(M(:,1) == 99) % search for 99 in col1 [row2,~] ...

oltre 2 anni fa | 0

Risposto

how to plot Double y axis?

For version 2016a aor later, use yyaxis instead x = [1 6 10 15 22]; y1 = [2 6 8 10 15]; y2 = [99 97 94 92 89]; [hAx,hLine1...

how to plot Double y axis?

For version 2016a aor later, use yyaxis instead x = [1 6 10 15 22]; y1 = [2 6 8 10 15]; y2 = [99 97 94 92 89]; [hAx,hLine1...

oltre 2 anni fa | 0

Risposto

Am unable to wrap my head on this question regarding for loop , can someone explain the question and maybe write the code please.

Why use a loop if it can be done without it A = [1 2 3; 4 5 6; 7 8 9]; [sum_of_elements] = halfsum(A) function [sum_of_elem...

Am unable to wrap my head on this question regarding for loop , can someone explain the question and maybe write the code please.

Why use a loop if it can be done without it A = [1 2 3; 4 5 6; 7 8 9]; [sum_of_elements] = halfsum(A) function [sum_of_elem...

oltre 2 anni fa | 1

| accettato

Risposto

How to select every 54th image in the folder?

I modified the code that I wrote for your last question as it might be easy to follow the same structure. % path to the folder...

How to select every 54th image in the folder?

I modified the code that I wrote for your last question as it might be easy to follow the same structure. % path to the folder...

quasi 3 anni fa | 1

| accettato

Risposto

How to apply multiple parameters function on all the matrices in the folder?

Read your .mat files Loop through them and find B Store that B array to a cell % path to the folder that contains .mat files ...

How to apply multiple parameters function on all the matrices in the folder?

Read your .mat files Loop through them and find B Store that B array to a cell % path to the folder that contains .mat files ...

quasi 3 anni fa | 1

| accettato

Risposto

I want to change the size of T so I can Add it to P2 (the size of T should be the size of P1 or the size of P2)

P1=[3 2 4;2 1 1;5 2 3;2 3 7]; P2=[2 6 1;1 3 5;4 2 1;5 2 1]; P1_Zero=pinv(P1); T=P1_Zero*P1; % create a new matrix of dimen...

I want to change the size of T so I can Add it to P2 (the size of T should be the size of P1 or the size of P2)

P1=[3 2 4;2 1 1;5 2 3;2 3 7]; P2=[2 6 1;1 3 5;4 2 1;5 2 1]; P1_Zero=pinv(P1); T=P1_Zero*P1; % create a new matrix of dimen...

quasi 3 anni fa | 0

| accettato

Risposto

how to develope loop to save the 'n' elements from the vectors

Although it is not prefered to name variables in a loop but if you striclty want to do this in loops than you can use eval(). No...

how to develope loop to save the 'n' elements from the vectors

Although it is not prefered to name variables in a loop but if you striclty want to do this in loops than you can use eval(). No...

quasi 3 anni fa | 1

Risposto

How to Copy Upper diagonal elements of matrix A into a new matrix.

A= [1 2 3 4; 2 1 3 4; 1 1 1 2; 1 0 0 1] M = zeros(size(A)); for row = 1:1:size(A,1) for col = row:1:size(A,2) M(row,col...

How to Copy Upper diagonal elements of matrix A into a new matrix.

A= [1 2 3 4; 2 1 3 4; 1 1 1 2; 1 0 0 1] M = zeros(size(A)); for row = 1:1:size(A,1) for col = row:1:size(A,2) M(row,col...

quasi 3 anni fa | 0

Risposto

BER Calculation of BPSK for custom demodtalor IP core

use biterr() and semilogy() to find bit errors and to plot BER curve clc clear close all % generate data to send x = 4*rand...

BER Calculation of BPSK for custom demodtalor IP core

use biterr() and semilogy() to find bit errors and to plot BER curve clc clear close all % generate data to send x = 4*rand...

quasi 3 anni fa | 0

Risposto

how to convert vector char to matrix char ?

How about using cell? X = 'ABCDEFGHIJKLMNOPQRSTWXYZ'; v = cellstr(num2cell(X)) By now you use access cells as v{2}, v{4} etc....

how to convert vector char to matrix char ?

How about using cell? X = 'ABCDEFGHIJKLMNOPQRSTWXYZ'; v = cellstr(num2cell(X)) By now you use access cells as v{2}, v{4} etc....

quasi 3 anni fa | 0

Risposto

How to create a vector of symbolic variables with specific labeling

Not the best way but will work good enough for small vectors vsym = sym('x',size(v)); for col = 1:1:size(v,2) char_str = ...

How to create a vector of symbolic variables with specific labeling

Not the best way but will work good enough for small vectors vsym = sym('x',size(v)); for col = 1:1:size(v,2) char_str = ...

quasi 3 anni fa | 0

Risposto

i want two responce on same plot

Try figure hold on step(g, 'r') title('approximate responce') step(c, 'g') grid on legend('step(g)', 'step(c)') or just ...

i want two responce on same plot

Try figure hold on step(g, 'r') title('approximate responce') step(c, 'g') grid on legend('step(g)', 'step(c)') or just ...

quasi 3 anni fa | 0

| accettato

Risposto

How to check if two elements are present in an array at once?

clc;clear all;close all; x = [1 5]; y = 2; used1 = [9 10]; A = [x y]; % concatenate x and y to check at once used1 = [used...

How to check if two elements are present in an array at once?

clc;clear all;close all; x = [1 5]; y = 2; used1 = [9 10]; A = [x y]; % concatenate x and y to check at once used1 = [used...

quasi 3 anni fa | 0

Risposto

how to form a matrix with non-numeral entries and then set conditions for each case

I have made some corrections in your code clc;clear all;close all NOH=3; NOC=2; Tetta=70*pi/180 A = {} for i=1:NOC+NOH ...

how to form a matrix with non-numeral entries and then set conditions for each case

I have made some corrections in your code clc;clear all;close all NOH=3; NOC=2; Tetta=70*pi/180 A = {} for i=1:NOC+NOH ...

quasi 3 anni fa | 0

| accettato

Risposto

Creating a mxn matrix that is all zeros except for the middle row and middle column which are 1s

M = zeros(7,5) M(:,ceil(size(M,2)/2)) = 1 M(ceil(size(M,1)/2),:) = 1

Creating a mxn matrix that is all zeros except for the middle row and middle column which are 1s

M = zeros(7,5) M(:,ceil(size(M,2)/2)) = 1 M(ceil(size(M,1)/2),:) = 1

quasi 3 anni fa | 0

Risposto

To find value of variable using iteration

What is your goal exactly? Do you want to find the value for x where the result is zero? You can find the roots using solve sym...

To find value of variable using iteration

What is your goal exactly? Do you want to find the value for x where the result is zero? You can find the roots using solve sym...

quasi 3 anni fa | 0

Risposto

I am getting wrong answer

You wrote a loop to run when err >= 20, its value is decreasing in the loop and when err<20 (in your case 10), why would it stil...

I am getting wrong answer

You wrote a loop to run when err >= 20, its value is decreasing in the loop and when err<20 (in your case 10), why would it stil...

quasi 3 anni fa | 0

Risposto

The result of the operation in the calculator and the result of the operation in matlab are different

You must have missed a zero from Db. I am getting the same answer from MATLAB and calculator that is 2145.833333

The result of the operation in the calculator and the result of the operation in matlab are different

You must have missed a zero from Db. I am getting the same answer from MATLAB and calculator that is 2145.833333

quasi 3 anni fa | 3

| accettato

Risposto

Naming cells in for loop

You want to create a cell array with 10 cells? If yes then use for i=1:10 c{i} = cell(2,1); end If you meant you want to...

Naming cells in for loop

You want to create a cell array with 10 cells? If yes then use for i=1:10 c{i} = cell(2,1); end If you meant you want to...

quasi 3 anni fa | 0

| accettato

Risposto

How to subtract corresponding elemets of corresponding columns of two matrices?

"each column of fisrt column P1 is being subtracted from corresponding elemt of Q1". That's a confusion. You meant rows, right?...

How to subtract corresponding elemets of corresponding columns of two matrices?

"each column of fisrt column P1 is being subtracted from corresponding elemt of Q1". That's a confusion. You meant rows, right?...

quasi 3 anni fa | 0

| accettato

Risposto

Find returns empty with inconsistent size

This command is for vectors and matrices. find(X > 0) returns the indices of the array X where elements are greater than zero. I...

Find returns empty with inconsistent size

This command is for vectors and matrices. find(X > 0) returns the indices of the array X where elements are greater than zero. I...

quasi 3 anni fa | 0

Risposto

Why do I receive Index exceeds the number of array elements (1)?

Your L = 10(a scaler). After second iteration, i = 2 and L(2) does not exist. That is why you are seeing that error. Secondly, o...

Why do I receive Index exceeds the number of array elements (1)?

Your L = 10(a scaler). After second iteration, i = 2 and L(2) does not exist. That is why you are seeing that error. Secondly, o...

quasi 3 anni fa | 0

Risposto

How can I convert double value to cell?

There are multiple ways t = magic(5); % double % method one. Convert single element x = t(1,2) x = num2cell(x) % method...

How can I convert double value to cell?

There are multiple ways t = magic(5); % double % method one. Convert single element x = t(1,2) x = num2cell(x) % method...

quasi 3 anni fa | 0

| accettato

Risposto

Decrementing step for loop I matlab

% start, step, and end points starty = 1; endy = 12; startx = 10; endx = 2; decrement = -1; y = zeros(1,12); for i = s...

Decrementing step for loop I matlab

% start, step, and end points starty = 1; endy = 12; startx = 10; endx = 2; decrement = -1; y = zeros(1,12); for i = s...

quasi 3 anni fa | 1