Community Profile # Chunru

Last seen: 1 day ago Active since 2013

Matlab user since 1990

#### Statistics

All
• • • • • • • • • • • • #### Content Feed

View by

How to plot a curve between 2 data sets
Do you mean Dp vs Q? %% input data P1=[2.3;3.9;3.5;4.8;5.5;6.3;7.4]; P2=[4.8;5.7;6.5;7.8;9.2;10.5;11.8]; D=[78;65;57;52;46;3...

1 day ago | 0

Find Command not working.
use abs(difference) to comapare the float numbers. T=[NaN 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9]; a=0.6; V=find(abs(T-a)<1e-10)...

2 days ago | 0

For rows and 2 columns, containing xOy coordinates of the point. Look for the two points with the furthest distance and return the row index of those two points.
n = 8; xy = rand(n, 2); d = pdist(xy); D = squareform(d) [~, idx]= max(D(:)); [i, j] = ind2sub([n n], idx)

3 days ago | 0

I would like to create a handle function by for loop in matlab, but it does not work. I will be thankful if some body help me.
a=[1 2 3]; b=[4 5 6] n=length(a); for i=1:n s{i}=@(x) a(i)*x-b(i)*x; end s{1}(3)

3 days ago | 1

each columun of a 2D matrix multiply with a 3D array
A=rand(20,30); B=rand(6,6,20); c=0; for j=1:30 d=0; for k=1:20 d=d+A(k,j)*B(:,:,k); end c=c+d;...

3 days ago | 0

Feature Input layer error MATLAB 2021a
featureInputLayer is Introduced in R2020b. Try: which featureInputLayer numFeatures = 21; numClasses = 3; layers = [ ...

3 days ago | 0

Can I get help with loops and char function?
n = 3; %input('Enter # of derivatives to compute (1-7): '); %prompts a value input syms x E = 2*x^9 + 3*x^6 - 8*x^2 for i=1:n...

3 days ago | 0

Change char to cell
msg{1} =['abc12';'def34'] msgc = cellstr(msg{1})

4 days ago | 0

How can I add sinusoidal signal and fft?
fs = 1000; f = [40 80 100 250]; % freq a = [1 2 3 1]; % amp p = randn(1,4)*2*pi; % phase t = (0...

5 days ago | 0

| accepted

How to view image from .MAT file
x = load("1.mat"); x.cjdata figure(1); imagesc(x.cjdata.image); axis image saveas(gcf, 'a.jpg'); figure(2); imagesc(x.cjdata...

5 days ago | 0

| accepted

Can you exclude dates in date range using xlim?
dn = now + [0:.5:48]/24; y = randn(size(dn)); subplot(311) plot(dn, y) datetick('x') subplot(312) idx = hour(dn)>7 &...

5 days ago | 0

| accepted

Modulus Arithmetic Function Not Working
715^17 is too big. You can use symbolic computation: r=rem(sym(715)^17,2773)

5 days ago | 0

| accepted

Storage results in an array
% Without loop x=[2,3,4,5,6]; y=x; y(x>4)=x(x>4).^2; y(x<=4)=x(x<=4)+2 % With loop x = [2,3,4,5,6]; y = zeros(size(x)); ...

5 days ago | 0

programme matlab pour calculer et trace l'histogramme d'une image

5 days ago | 0

Matrix Multiplication for each row
n = 5; %100000 A = randn(n, 2); B = [4 2; 2 3]; if n<100 d1 = diag(A*B*A') end d2 = sum(A.*(A*B'), 2)

5 days ago | 0

| accepted

Plotting pie charts over GraphPlot
Here is the updated answer. We play with the properties of pie_chart this time. clf s = [1 1 1 1 2 2 3 4 4 5 6]; t = [2 3 4 ...

7 days ago | 1

| accepted

How to change the position of labels on plot?
Add a number to z in "text" command. data = [1,0,3.8*10^8 2,1,4.2*10^7 3,2,1.5*10^7 4,3,7.8*10^7] ; x = data(:,1) ; y = ...

7 days ago | 0

| accepted

Plotting over a Range of Values
Use the array operator .* ./ .^2 for arrays. altitude = 150:1:1000; mu_earth = 3.986*10^5; %km3/s2 orbital_speed = sqrt(mu_ea...

7 days ago | 0

| accepted

Fitnet: Out of memory error solved by transposing?
When you use "my_ANN = train (net_set, input,output)", your network will have a input/output size of 49736, which results in man...

7 days ago | 1

| accepted

How can I only select table data from a text file.

9 days ago | 0

Removing commas between columns in text data
test = {'Sometimes, ,, I, use, commas, .' 'I, like, writing, ,, I, like, reading'}; test = regexprep(test, ',\s', ' ') ...

10 days ago | 0

Show limited digits numbers.
You can use fprintf with format specifier to format the print out. "doc fprintf". A=2.54357766; fprintf('%.6f\n', A);

10 days ago | 0

Change string words to number in table
% Assume the column has the data x.omst=["Clouds"; "Rain"; "Clear"] % You can use the categorical data x.omst = categorical(x...

11 days ago | 0

| accepted

Deleting unnecessary values in numerical array
% Assume that your data in second column is sorted. x = [ 1420 1 1410 1 1400 1 1390 0.9 1380 0.8 1370 0.7 1300 0 1290 0...

11 days ago | 0

| accepted

99x99 matrix
% For time comparison: n = 1000; timeit(@() bidiag1(n)) timeit(@() bidiag2(n)) timeit(@() bidiag3(n)) function bidiag1(n)...

11 days ago | 0

99x99 matrix
n = 9; %99 A = eye(n); A(n:n-1:n*n-1) = 1; % anti-diagonal A

11 days ago | 0

How can I generate a square lattice undirected graph?
n = 10; A = delsq(numgrid('S',n+2)); G = graph(A,'omitselfloops'); h = plot(G); h.XData = floor((0:99)/10); h.YData = rem((...

11 days ago | 0

| accepted

add an line for the coasts of the continents used for the geodensityplot in the mapping toolbox
mapping toolbox has the convention of lat-lon coordinates rather than lon-lat. try the following in your code: lon = linspace(...

11 days ago | 0

| accepted