Category: Matlab
Category Archives: Matlab
VerifyEqual within a time interval
Hello, I have been assigned a series of tests to be completed on several floating point variables. The assignment requires me to check whether the Expected value is the same as the Actual value. However, it may take a few milliseconds for the Actual value to reach the same status as the Expected value, and the verifyEqual function does not seem to consider this scenario.
I’d like to know if there is some sort of workaround for this situation. Basically, if A is the Actual value and E the Expected value, I’d like to modify (somehow) the verifyEqual function so that it returns a passing test if A == E with a time delay of approx. 3 milliseconds.
Thank you for your cooperation.Hello, I have been assigned a series of tests to be completed on several floating point variables. The assignment requires me to check whether the Expected value is the same as the Actual value. However, it may take a few milliseconds for the Actual value to reach the same status as the Expected value, and the verifyEqual function does not seem to consider this scenario.
I’d like to know if there is some sort of workaround for this situation. Basically, if A is the Actual value and E the Expected value, I’d like to modify (somehow) the verifyEqual function so that it returns a passing test if A == E with a time delay of approx. 3 milliseconds.
Thank you for your cooperation. Hello, I have been assigned a series of tests to be completed on several floating point variables. The assignment requires me to check whether the Expected value is the same as the Actual value. However, it may take a few milliseconds for the Actual value to reach the same status as the Expected value, and the verifyEqual function does not seem to consider this scenario.
I’d like to know if there is some sort of workaround for this situation. Basically, if A is the Actual value and E the Expected value, I’d like to modify (somehow) the verifyEqual function so that it returns a passing test if A == E with a time delay of approx. 3 milliseconds.
Thank you for your cooperation. matlab function, testcase, guide, solve, time MATLAB Answers — New Questions
Adjust the fitting for non-unique values data (alternative to the fuction smoothing spline, createFit.f)
Good morning everyone,
I am trying to extract the fracture aperture from a tomography image. I have written the code for the extraction, and everything works using the fitting smoothing spline (createFit function attached) for clu_sli_12.mat and I_12.mat, but not on clu_sli_1400.mat and I_1400.mat in which we have non-unique data (presented directly in the code below). The variable clu_sli_1400 represents the point cloud used as reference for selecting data in the tomography slice (variable I_1400). We tried using other functions in matlab, without success. Can anybody help suggesting a specific function for fitting this data?
thanks in advance for any help!!!!!!!!
clear;
close all;
clc;
warning off;
load(‘I_1400.mat’)
load(‘clu_sli_1400.mat’)
voxel_size=70.69*10^-3;
%% Iteration on the slices
mean_widths = [];
std_widths = [];
min_widths = [];
max_widths = [];
areas = [];
% for ii = 12 %we have to iterate to ii = 12 and ii = 1400 (the last one not working properly on the fitting)
% fitting data
X = clu_sli(:,1);
Y = clu_sli(:,2);
% Create model fitting
[fitresult, gof] = createFit(X, Y);
% Calcolare i valori della curva di fitting
vv = ppval(fitresult.p, X);
% Calcolare la prima derivata della curva di fitting
d1 = ppval(fnder(fitresult.p, 1), X);
% Calcolare la normale alla curva di fitting
epsilon = 1e-10; % Evita la divisione per zero
nn = 1 ./ (d1 + epsilon);
% Calcolare gli angoli delle normali
theta = atan(-1 ./ d1); % Angolo della normale (in radianti)
% Calcolare le componenti della normale
normal_x = cos(theta); % Componente x della normale
normal_y = sin(theta); % Componente y della normale
% Calcolare l’ampiezza della crepa e visualizzare i segmenti
span = 50;
largh = zeros(size(clu_sli, 1), 1);
% Creare una figura con due subplot
figure;
% Primo subplot: Visualizzare la slice con i pallini rossi
subplot(1, 2, 1);
pcolor(I);
shading interp;
axis equal;
hold on;
scatter(clu_sli(:,1), clu_sli(:,2), ‘r’);
xlabel(‘X’);
ylabel(‘Y’);
% Secondo subplot: Visualizzare la slice con i segmenti verdi
subplot(1, 2, 2);
pcolor(I);
shading interp;
axis equal;
hold on;
scatter(clu_sli(:,1), clu_sli(:,2), ‘r’);
plot(X, vv, ‘b’, ‘LineWidth’, 2);
quiver(X, vv, normal_x, normal_y, 0.5, ‘k’, ‘LineWidth’, 1);
intensity_profiles = cell(size(clu_sli, 1), 1);
vet_in = zeros(size(clu_sli, 1), 2);
vet_fin = zeros(size(clu_sli, 1), 2);
for kk = 1:size(clu_sli, 1)
c = round(X(kk));
r = round(vv(kk));
% Genera i pixel lungo la normale
x_profile = round(c + (-span:span) * normal_x(kk));
y_profile = round(r + (-span:span) * normal_y(kk));
% Assicurarsi che i pixel siano all’interno dell’immagine
valid_idx = x_profile > 0 & x_profile <= size(I, 2) & y_profile > 0 & y_profile <= size(I, 1);
x_profile = x_profile(valid_idx);
y_profile = y_profile(valid_idx);
% Estrarre i valori del profilo dall’immagine
profilo = I(sub2ind(size(I), y_profile, x_profile));
intensity_profiles{kk} = profilo;
% Calcolare l’ampiezza della crepa
largh(kk) = conv_crepa(profilo);
% Calcolare i punti del segmento di larghezza
half_width = largh(kk) / 2;
segment_x = [c – half_width * normal_x(kk), c + half_width * normal_x(kk)];
segment_y = [r – half_width * normal_y(kk), r + half_width * normal_y(kk)];
vet_in(kk,1) = c – half_width * normal_x(kk);
vet_fin(kk,1) = c + half_width * normal_x(kk);
vet_in(kk,2) = r – half_width * normal_y(kk);
vet_fin(kk,2) = r + half_width * normal_y(kk);
% Visualizzare il segmento di larghezza
plot(segment_x, segment_y, ‘g’, ‘LineWidth’, 2);
end
hold off;
% Calcolare la media, la deviazione standard, il minimo e il massimo della larghezza della crepa
mean_width = mean(largh, ‘omitnan’);
std_width = std(largh, ‘omitnan’);
min_width = min(largh, [], ‘omitnan’);
max_width = max(largh, [], ‘omitnan’);
mean_widths = [mean_widths; mean_width];
std_widths = [std_widths; std_width];
min_widths = [min_widths; min_width];
max_widths = [max_widths; max_width];
% Calcolo dell’area all’interno delle curve usando trapz
% Creazione del poligono per calcolare l’area
all_x = [vet_in(:,1); flip(vet_fin(:,1))];
all_y = [vet_in(:,2); flip(vet_fin(:,2))];
% Rimuovi i NaN
valid_idx = ~isnan(all_x) & ~isnan(all_y);
all_x = all_x(valid_idx);
all_y = all_y(valid_idx);
% Assicurarsi che i punti formino un poligono chiuso
if length(all_x) > 1 && (all_x(1) ~= all_x(end) || all_y(1) ~= all_y(end))
all_x(end+1) = all_x(1);
all_y(end+1) = all_y(1);
end
% Calcolo dell’area del poligono usando trapz
area = trapz(all_x, all_y);
areas = [areas; area];
title(‘Area Between Curves per Slice’);
%% calcoli in mm
areas_mm = areas.* voxel_size^2
std_mm=std_widths.*voxel_size
mean_mm=mean_widths.*voxel_size
min_mm=min_widths.*voxel_size
max_mm=max_widths.*voxel_sizeGood morning everyone,
I am trying to extract the fracture aperture from a tomography image. I have written the code for the extraction, and everything works using the fitting smoothing spline (createFit function attached) for clu_sli_12.mat and I_12.mat, but not on clu_sli_1400.mat and I_1400.mat in which we have non-unique data (presented directly in the code below). The variable clu_sli_1400 represents the point cloud used as reference for selecting data in the tomography slice (variable I_1400). We tried using other functions in matlab, without success. Can anybody help suggesting a specific function for fitting this data?
thanks in advance for any help!!!!!!!!
clear;
close all;
clc;
warning off;
load(‘I_1400.mat’)
load(‘clu_sli_1400.mat’)
voxel_size=70.69*10^-3;
%% Iteration on the slices
mean_widths = [];
std_widths = [];
min_widths = [];
max_widths = [];
areas = [];
% for ii = 12 %we have to iterate to ii = 12 and ii = 1400 (the last one not working properly on the fitting)
% fitting data
X = clu_sli(:,1);
Y = clu_sli(:,2);
% Create model fitting
[fitresult, gof] = createFit(X, Y);
% Calcolare i valori della curva di fitting
vv = ppval(fitresult.p, X);
% Calcolare la prima derivata della curva di fitting
d1 = ppval(fnder(fitresult.p, 1), X);
% Calcolare la normale alla curva di fitting
epsilon = 1e-10; % Evita la divisione per zero
nn = 1 ./ (d1 + epsilon);
% Calcolare gli angoli delle normali
theta = atan(-1 ./ d1); % Angolo della normale (in radianti)
% Calcolare le componenti della normale
normal_x = cos(theta); % Componente x della normale
normal_y = sin(theta); % Componente y della normale
% Calcolare l’ampiezza della crepa e visualizzare i segmenti
span = 50;
largh = zeros(size(clu_sli, 1), 1);
% Creare una figura con due subplot
figure;
% Primo subplot: Visualizzare la slice con i pallini rossi
subplot(1, 2, 1);
pcolor(I);
shading interp;
axis equal;
hold on;
scatter(clu_sli(:,1), clu_sli(:,2), ‘r’);
xlabel(‘X’);
ylabel(‘Y’);
% Secondo subplot: Visualizzare la slice con i segmenti verdi
subplot(1, 2, 2);
pcolor(I);
shading interp;
axis equal;
hold on;
scatter(clu_sli(:,1), clu_sli(:,2), ‘r’);
plot(X, vv, ‘b’, ‘LineWidth’, 2);
quiver(X, vv, normal_x, normal_y, 0.5, ‘k’, ‘LineWidth’, 1);
intensity_profiles = cell(size(clu_sli, 1), 1);
vet_in = zeros(size(clu_sli, 1), 2);
vet_fin = zeros(size(clu_sli, 1), 2);
for kk = 1:size(clu_sli, 1)
c = round(X(kk));
r = round(vv(kk));
% Genera i pixel lungo la normale
x_profile = round(c + (-span:span) * normal_x(kk));
y_profile = round(r + (-span:span) * normal_y(kk));
% Assicurarsi che i pixel siano all’interno dell’immagine
valid_idx = x_profile > 0 & x_profile <= size(I, 2) & y_profile > 0 & y_profile <= size(I, 1);
x_profile = x_profile(valid_idx);
y_profile = y_profile(valid_idx);
% Estrarre i valori del profilo dall’immagine
profilo = I(sub2ind(size(I), y_profile, x_profile));
intensity_profiles{kk} = profilo;
% Calcolare l’ampiezza della crepa
largh(kk) = conv_crepa(profilo);
% Calcolare i punti del segmento di larghezza
half_width = largh(kk) / 2;
segment_x = [c – half_width * normal_x(kk), c + half_width * normal_x(kk)];
segment_y = [r – half_width * normal_y(kk), r + half_width * normal_y(kk)];
vet_in(kk,1) = c – half_width * normal_x(kk);
vet_fin(kk,1) = c + half_width * normal_x(kk);
vet_in(kk,2) = r – half_width * normal_y(kk);
vet_fin(kk,2) = r + half_width * normal_y(kk);
% Visualizzare il segmento di larghezza
plot(segment_x, segment_y, ‘g’, ‘LineWidth’, 2);
end
hold off;
% Calcolare la media, la deviazione standard, il minimo e il massimo della larghezza della crepa
mean_width = mean(largh, ‘omitnan’);
std_width = std(largh, ‘omitnan’);
min_width = min(largh, [], ‘omitnan’);
max_width = max(largh, [], ‘omitnan’);
mean_widths = [mean_widths; mean_width];
std_widths = [std_widths; std_width];
min_widths = [min_widths; min_width];
max_widths = [max_widths; max_width];
% Calcolo dell’area all’interno delle curve usando trapz
% Creazione del poligono per calcolare l’area
all_x = [vet_in(:,1); flip(vet_fin(:,1))];
all_y = [vet_in(:,2); flip(vet_fin(:,2))];
% Rimuovi i NaN
valid_idx = ~isnan(all_x) & ~isnan(all_y);
all_x = all_x(valid_idx);
all_y = all_y(valid_idx);
% Assicurarsi che i punti formino un poligono chiuso
if length(all_x) > 1 && (all_x(1) ~= all_x(end) || all_y(1) ~= all_y(end))
all_x(end+1) = all_x(1);
all_y(end+1) = all_y(1);
end
% Calcolo dell’area del poligono usando trapz
area = trapz(all_x, all_y);
areas = [areas; area];
title(‘Area Between Curves per Slice’);
%% calcoli in mm
areas_mm = areas.* voxel_size^2
std_mm=std_widths.*voxel_size
mean_mm=mean_widths.*voxel_size
min_mm=min_widths.*voxel_size
max_mm=max_widths.*voxel_size Good morning everyone,
I am trying to extract the fracture aperture from a tomography image. I have written the code for the extraction, and everything works using the fitting smoothing spline (createFit function attached) for clu_sli_12.mat and I_12.mat, but not on clu_sli_1400.mat and I_1400.mat in which we have non-unique data (presented directly in the code below). The variable clu_sli_1400 represents the point cloud used as reference for selecting data in the tomography slice (variable I_1400). We tried using other functions in matlab, without success. Can anybody help suggesting a specific function for fitting this data?
thanks in advance for any help!!!!!!!!
clear;
close all;
clc;
warning off;
load(‘I_1400.mat’)
load(‘clu_sli_1400.mat’)
voxel_size=70.69*10^-3;
%% Iteration on the slices
mean_widths = [];
std_widths = [];
min_widths = [];
max_widths = [];
areas = [];
% for ii = 12 %we have to iterate to ii = 12 and ii = 1400 (the last one not working properly on the fitting)
% fitting data
X = clu_sli(:,1);
Y = clu_sli(:,2);
% Create model fitting
[fitresult, gof] = createFit(X, Y);
% Calcolare i valori della curva di fitting
vv = ppval(fitresult.p, X);
% Calcolare la prima derivata della curva di fitting
d1 = ppval(fnder(fitresult.p, 1), X);
% Calcolare la normale alla curva di fitting
epsilon = 1e-10; % Evita la divisione per zero
nn = 1 ./ (d1 + epsilon);
% Calcolare gli angoli delle normali
theta = atan(-1 ./ d1); % Angolo della normale (in radianti)
% Calcolare le componenti della normale
normal_x = cos(theta); % Componente x della normale
normal_y = sin(theta); % Componente y della normale
% Calcolare l’ampiezza della crepa e visualizzare i segmenti
span = 50;
largh = zeros(size(clu_sli, 1), 1);
% Creare una figura con due subplot
figure;
% Primo subplot: Visualizzare la slice con i pallini rossi
subplot(1, 2, 1);
pcolor(I);
shading interp;
axis equal;
hold on;
scatter(clu_sli(:,1), clu_sli(:,2), ‘r’);
xlabel(‘X’);
ylabel(‘Y’);
% Secondo subplot: Visualizzare la slice con i segmenti verdi
subplot(1, 2, 2);
pcolor(I);
shading interp;
axis equal;
hold on;
scatter(clu_sli(:,1), clu_sli(:,2), ‘r’);
plot(X, vv, ‘b’, ‘LineWidth’, 2);
quiver(X, vv, normal_x, normal_y, 0.5, ‘k’, ‘LineWidth’, 1);
intensity_profiles = cell(size(clu_sli, 1), 1);
vet_in = zeros(size(clu_sli, 1), 2);
vet_fin = zeros(size(clu_sli, 1), 2);
for kk = 1:size(clu_sli, 1)
c = round(X(kk));
r = round(vv(kk));
% Genera i pixel lungo la normale
x_profile = round(c + (-span:span) * normal_x(kk));
y_profile = round(r + (-span:span) * normal_y(kk));
% Assicurarsi che i pixel siano all’interno dell’immagine
valid_idx = x_profile > 0 & x_profile <= size(I, 2) & y_profile > 0 & y_profile <= size(I, 1);
x_profile = x_profile(valid_idx);
y_profile = y_profile(valid_idx);
% Estrarre i valori del profilo dall’immagine
profilo = I(sub2ind(size(I), y_profile, x_profile));
intensity_profiles{kk} = profilo;
% Calcolare l’ampiezza della crepa
largh(kk) = conv_crepa(profilo);
% Calcolare i punti del segmento di larghezza
half_width = largh(kk) / 2;
segment_x = [c – half_width * normal_x(kk), c + half_width * normal_x(kk)];
segment_y = [r – half_width * normal_y(kk), r + half_width * normal_y(kk)];
vet_in(kk,1) = c – half_width * normal_x(kk);
vet_fin(kk,1) = c + half_width * normal_x(kk);
vet_in(kk,2) = r – half_width * normal_y(kk);
vet_fin(kk,2) = r + half_width * normal_y(kk);
% Visualizzare il segmento di larghezza
plot(segment_x, segment_y, ‘g’, ‘LineWidth’, 2);
end
hold off;
% Calcolare la media, la deviazione standard, il minimo e il massimo della larghezza della crepa
mean_width = mean(largh, ‘omitnan’);
std_width = std(largh, ‘omitnan’);
min_width = min(largh, [], ‘omitnan’);
max_width = max(largh, [], ‘omitnan’);
mean_widths = [mean_widths; mean_width];
std_widths = [std_widths; std_width];
min_widths = [min_widths; min_width];
max_widths = [max_widths; max_width];
% Calcolo dell’area all’interno delle curve usando trapz
% Creazione del poligono per calcolare l’area
all_x = [vet_in(:,1); flip(vet_fin(:,1))];
all_y = [vet_in(:,2); flip(vet_fin(:,2))];
% Rimuovi i NaN
valid_idx = ~isnan(all_x) & ~isnan(all_y);
all_x = all_x(valid_idx);
all_y = all_y(valid_idx);
% Assicurarsi che i punti formino un poligono chiuso
if length(all_x) > 1 && (all_x(1) ~= all_x(end) || all_y(1) ~= all_y(end))
all_x(end+1) = all_x(1);
all_y(end+1) = all_y(1);
end
% Calcolo dell’area del poligono usando trapz
area = trapz(all_x, all_y);
areas = [areas; area];
title(‘Area Between Curves per Slice’);
%% calcoli in mm
areas_mm = areas.* voxel_size^2
std_mm=std_widths.*voxel_size
mean_mm=mean_widths.*voxel_size
min_mm=min_widths.*voxel_size
max_mm=max_widths.*voxel_size curve fitting, non-unique data, createfit MATLAB Answers — New Questions
A simple allocation of array places to zero does not work in MATLAB R2020B
I have a numeric array KSE
I have identified a number of locations where there are peaks,
locations =
Columns 1 through 10
147 827 3772 4762 5192 5618 6048 6481 6915 7350
Columns 11 through 20
7781 8206 8637 9070 9502 9938 10367 10793 11225 11657
Columns 21 through 26
12922 13876 20315 23377 24431 25492
I have identified in that array a number of locations where there are short lived transients, a number of which I wish to remove.
Those unwanted transients are identified by
ii =
1 2 3 21 22 23 24 25 26
The command
KSE(locations(ii)-50:locations(ii)+50)=0
is meant to replace 50 array elements on either side of the transient location with a zero.
It works well at the first location but not in the remaining 8 locations!
Is this a bug or am I doing some sort of stupid coding mistake?
Any soultions would be appreciated!I have a numeric array KSE
I have identified a number of locations where there are peaks,
locations =
Columns 1 through 10
147 827 3772 4762 5192 5618 6048 6481 6915 7350
Columns 11 through 20
7781 8206 8637 9070 9502 9938 10367 10793 11225 11657
Columns 21 through 26
12922 13876 20315 23377 24431 25492
I have identified in that array a number of locations where there are short lived transients, a number of which I wish to remove.
Those unwanted transients are identified by
ii =
1 2 3 21 22 23 24 25 26
The command
KSE(locations(ii)-50:locations(ii)+50)=0
is meant to replace 50 array elements on either side of the transient location with a zero.
It works well at the first location but not in the remaining 8 locations!
Is this a bug or am I doing some sort of stupid coding mistake?
Any soultions would be appreciated! I have a numeric array KSE
I have identified a number of locations where there are peaks,
locations =
Columns 1 through 10
147 827 3772 4762 5192 5618 6048 6481 6915 7350
Columns 11 through 20
7781 8206 8637 9070 9502 9938 10367 10793 11225 11657
Columns 21 through 26
12922 13876 20315 23377 24431 25492
I have identified in that array a number of locations where there are short lived transients, a number of which I wish to remove.
Those unwanted transients are identified by
ii =
1 2 3 21 22 23 24 25 26
The command
KSE(locations(ii)-50:locations(ii)+50)=0
is meant to replace 50 array elements on either side of the transient location with a zero.
It works well at the first location but not in the remaining 8 locations!
Is this a bug or am I doing some sort of stupid coding mistake?
Any soultions would be appreciated! setting array elements to zero MATLAB Answers — New Questions
I want to add two histograms with error bars to a piece of code I already have that is generating two plots
I have a piece of code that is currently calculating stress/strain and force/extension.
It groups them into catagories based on the temperature and time they were sintered for.
I would like to add histograsm that can also show the modulus of elasticity and the ultimate tensile strength for these groups. The modulus of elasticity should be for say a range from ~0.05 to 0.15 extension, or similar. The error bars should show +/- the stdev for the data sets
would also like to make it so that the legend expressly states the sintering cycle.
For example ‘conventional sintering’ two-stage sintering’, ‘sintered at x°C for x hours’ etc
below is the code
clear
close all
Nsamples = 14;
G=ones(1,2*Nsamples);
G(1:12)=1;
G([2:1:4 10:1:11])=2;
G(5:1:9)=3;
G(13:14)=4;
%%
load(‘E:DICsintering_dataOXmcdata.mat’)
% G(15)=5;
% G(16)=6;
% G(13:14)=5;
% M={‘x’,’+’,’*’,’s’,’d’}; % a marker for each group
C={‘r’,’b’,’m’,’g’,’m’,’y’}; % and a color
L = 90; % coupon gauge section (mm)
A = 18; % coupon cross-sectional area (mm^2)
figure(1);
hold on
figure(2);
hold on
for k = 1:Nsamples
file_name = [‘Sample’ num2str(k) ‘.csv’];
T = readtable(file_name,’VariableNamingRule’,’preserve’);
[test(k).disp,test(k).force,test(k).eyy] = post_fun(T);
ig=G(k); % get group id for kth file
figure(1)
% h(k) = plot(test(k).disp,test(k).force,’LineWidth’,2,’Marker’,M(ig),’Color’,C{ig});
h(k) = plot(test(k).disp,test(k).force,’LineWidth’,2,’Color’,C{ig});
figure(2)
% g(k) = plot(test(k).eyy*100,1000*test(k).force/A,’LineWidth’,2,’Marker’,M(ig),’Color’,C{ig});
g(k) = plot(test(k).eyy*100,1000*test(k).force/A,’LineWidth’,2,’Color’,C{ig});
leg_string{k} = [‘Sintering schedule ‘ num2str(ig)];
end
%
%%
figure(1)
set(gcf,’Position’,[200 200 1024 768],’Color’,[1 1 1]);
set(gca,’FontSize’,24);
xlabel(‘Displacement (mm)’,’FontSize’,32,’Interpreter’,’latex’);
ylabel(‘Force (kN)’,’FontSize’,32,’Interpreter’,’latex’);
box on
grid on
title(‘Force / extension curves for of various sintering schedules’,’FontSize’, 20,’Interpreter’,’latex’)
legend(h([1 2 5 13]),leg_string([1 2 5 13]),’FontSize’,28,’Interpreter’,’latex’,’location’,’southeast’);
%%
figure(2)
set(gcf,’Position’,[200 200 1024 768],’Color’,[1 1 1]);
set(gca,’FontSize’,24);
xlabel(‘Strain (%)’,’FontSize’,32,’Interpreter’,’latex’);
ylabel(‘Stress (MPa)’,’FontSize’,32,’Interpreter’,’latex’);
box on
grid on
title(‘Stress / strain curves for of various sintering schedules’,’FontSize’, 20,’Interpreter’,’latex’)
legend(g([1 2 5 13]),leg_string([1 2 5 13]),’FontSize’,28,’Interpreter’,’latex’,’location’,’southeast’);
%
plot(OXmcdata(:,1),OXmcdata(:,2),’DisplayName’,’Farhandi et al (2021)’,’LineWidth’,3,’Color’,’k’,’LineStyle’,’–‘);
%
xlim([0 3E-1]);
ylim([0 350]);
%%
function [displ,force,eyy] = post_fun(T)
displ=T{:,4};
force=T{:,end};
eyy =T{:,10};
ix=all(isfinite([displ force eyy]),2) & all([displ force eyy]>0,2);
displ=displ(ix);
force=force(ix);
eyy=eyy(ix);
[~,imax] = max(force);
displ(imax+1:end) = [];
force(imax+1:end) = [];
eyy(imax+1:end) = [];
end
Hopefully you can help.
Thanks
AlexI have a piece of code that is currently calculating stress/strain and force/extension.
It groups them into catagories based on the temperature and time they were sintered for.
I would like to add histograsm that can also show the modulus of elasticity and the ultimate tensile strength for these groups. The modulus of elasticity should be for say a range from ~0.05 to 0.15 extension, or similar. The error bars should show +/- the stdev for the data sets
would also like to make it so that the legend expressly states the sintering cycle.
For example ‘conventional sintering’ two-stage sintering’, ‘sintered at x°C for x hours’ etc
below is the code
clear
close all
Nsamples = 14;
G=ones(1,2*Nsamples);
G(1:12)=1;
G([2:1:4 10:1:11])=2;
G(5:1:9)=3;
G(13:14)=4;
%%
load(‘E:DICsintering_dataOXmcdata.mat’)
% G(15)=5;
% G(16)=6;
% G(13:14)=5;
% M={‘x’,’+’,’*’,’s’,’d’}; % a marker for each group
C={‘r’,’b’,’m’,’g’,’m’,’y’}; % and a color
L = 90; % coupon gauge section (mm)
A = 18; % coupon cross-sectional area (mm^2)
figure(1);
hold on
figure(2);
hold on
for k = 1:Nsamples
file_name = [‘Sample’ num2str(k) ‘.csv’];
T = readtable(file_name,’VariableNamingRule’,’preserve’);
[test(k).disp,test(k).force,test(k).eyy] = post_fun(T);
ig=G(k); % get group id for kth file
figure(1)
% h(k) = plot(test(k).disp,test(k).force,’LineWidth’,2,’Marker’,M(ig),’Color’,C{ig});
h(k) = plot(test(k).disp,test(k).force,’LineWidth’,2,’Color’,C{ig});
figure(2)
% g(k) = plot(test(k).eyy*100,1000*test(k).force/A,’LineWidth’,2,’Marker’,M(ig),’Color’,C{ig});
g(k) = plot(test(k).eyy*100,1000*test(k).force/A,’LineWidth’,2,’Color’,C{ig});
leg_string{k} = [‘Sintering schedule ‘ num2str(ig)];
end
%
%%
figure(1)
set(gcf,’Position’,[200 200 1024 768],’Color’,[1 1 1]);
set(gca,’FontSize’,24);
xlabel(‘Displacement (mm)’,’FontSize’,32,’Interpreter’,’latex’);
ylabel(‘Force (kN)’,’FontSize’,32,’Interpreter’,’latex’);
box on
grid on
title(‘Force / extension curves for of various sintering schedules’,’FontSize’, 20,’Interpreter’,’latex’)
legend(h([1 2 5 13]),leg_string([1 2 5 13]),’FontSize’,28,’Interpreter’,’latex’,’location’,’southeast’);
%%
figure(2)
set(gcf,’Position’,[200 200 1024 768],’Color’,[1 1 1]);
set(gca,’FontSize’,24);
xlabel(‘Strain (%)’,’FontSize’,32,’Interpreter’,’latex’);
ylabel(‘Stress (MPa)’,’FontSize’,32,’Interpreter’,’latex’);
box on
grid on
title(‘Stress / strain curves for of various sintering schedules’,’FontSize’, 20,’Interpreter’,’latex’)
legend(g([1 2 5 13]),leg_string([1 2 5 13]),’FontSize’,28,’Interpreter’,’latex’,’location’,’southeast’);
%
plot(OXmcdata(:,1),OXmcdata(:,2),’DisplayName’,’Farhandi et al (2021)’,’LineWidth’,3,’Color’,’k’,’LineStyle’,’–‘);
%
xlim([0 3E-1]);
ylim([0 350]);
%%
function [displ,force,eyy] = post_fun(T)
displ=T{:,4};
force=T{:,end};
eyy =T{:,10};
ix=all(isfinite([displ force eyy]),2) & all([displ force eyy]>0,2);
displ=displ(ix);
force=force(ix);
eyy=eyy(ix);
[~,imax] = max(force);
displ(imax+1:end) = [];
force(imax+1:end) = [];
eyy(imax+1:end) = [];
end
Hopefully you can help.
Thanks
Alex I have a piece of code that is currently calculating stress/strain and force/extension.
It groups them into catagories based on the temperature and time they were sintered for.
I would like to add histograsm that can also show the modulus of elasticity and the ultimate tensile strength for these groups. The modulus of elasticity should be for say a range from ~0.05 to 0.15 extension, or similar. The error bars should show +/- the stdev for the data sets
would also like to make it so that the legend expressly states the sintering cycle.
For example ‘conventional sintering’ two-stage sintering’, ‘sintered at x°C for x hours’ etc
below is the code
clear
close all
Nsamples = 14;
G=ones(1,2*Nsamples);
G(1:12)=1;
G([2:1:4 10:1:11])=2;
G(5:1:9)=3;
G(13:14)=4;
%%
load(‘E:DICsintering_dataOXmcdata.mat’)
% G(15)=5;
% G(16)=6;
% G(13:14)=5;
% M={‘x’,’+’,’*’,’s’,’d’}; % a marker for each group
C={‘r’,’b’,’m’,’g’,’m’,’y’}; % and a color
L = 90; % coupon gauge section (mm)
A = 18; % coupon cross-sectional area (mm^2)
figure(1);
hold on
figure(2);
hold on
for k = 1:Nsamples
file_name = [‘Sample’ num2str(k) ‘.csv’];
T = readtable(file_name,’VariableNamingRule’,’preserve’);
[test(k).disp,test(k).force,test(k).eyy] = post_fun(T);
ig=G(k); % get group id for kth file
figure(1)
% h(k) = plot(test(k).disp,test(k).force,’LineWidth’,2,’Marker’,M(ig),’Color’,C{ig});
h(k) = plot(test(k).disp,test(k).force,’LineWidth’,2,’Color’,C{ig});
figure(2)
% g(k) = plot(test(k).eyy*100,1000*test(k).force/A,’LineWidth’,2,’Marker’,M(ig),’Color’,C{ig});
g(k) = plot(test(k).eyy*100,1000*test(k).force/A,’LineWidth’,2,’Color’,C{ig});
leg_string{k} = [‘Sintering schedule ‘ num2str(ig)];
end
%
%%
figure(1)
set(gcf,’Position’,[200 200 1024 768],’Color’,[1 1 1]);
set(gca,’FontSize’,24);
xlabel(‘Displacement (mm)’,’FontSize’,32,’Interpreter’,’latex’);
ylabel(‘Force (kN)’,’FontSize’,32,’Interpreter’,’latex’);
box on
grid on
title(‘Force / extension curves for of various sintering schedules’,’FontSize’, 20,’Interpreter’,’latex’)
legend(h([1 2 5 13]),leg_string([1 2 5 13]),’FontSize’,28,’Interpreter’,’latex’,’location’,’southeast’);
%%
figure(2)
set(gcf,’Position’,[200 200 1024 768],’Color’,[1 1 1]);
set(gca,’FontSize’,24);
xlabel(‘Strain (%)’,’FontSize’,32,’Interpreter’,’latex’);
ylabel(‘Stress (MPa)’,’FontSize’,32,’Interpreter’,’latex’);
box on
grid on
title(‘Stress / strain curves for of various sintering schedules’,’FontSize’, 20,’Interpreter’,’latex’)
legend(g([1 2 5 13]),leg_string([1 2 5 13]),’FontSize’,28,’Interpreter’,’latex’,’location’,’southeast’);
%
plot(OXmcdata(:,1),OXmcdata(:,2),’DisplayName’,’Farhandi et al (2021)’,’LineWidth’,3,’Color’,’k’,’LineStyle’,’–‘);
%
xlim([0 3E-1]);
ylim([0 350]);
%%
function [displ,force,eyy] = post_fun(T)
displ=T{:,4};
force=T{:,end};
eyy =T{:,10};
ix=all(isfinite([displ force eyy]),2) & all([displ force eyy]>0,2);
displ=displ(ix);
force=force(ix);
eyy=eyy(ix);
[~,imax] = max(force);
displ(imax+1:end) = [];
force(imax+1:end) = [];
eyy(imax+1:end) = [];
end
Hopefully you can help.
Thanks
Alex histogram, bar, error, errorbars MATLAB Answers — New Questions
Searching for the nearest point on a grid using dsearchn
I am trying to compare field data with classified sattellite imagery.
What I am aiming for is to find the nearest pixel in the sattellite image to the location of the field data.
The coordinates of the pixels are in X & Y represented by blue circles below, spacing is 30m x 30m.
The coordinates of the field data is in TransectDataStats.Easting & .Northing represented by "x’s" below.
The dots are the "closest point" as determined by the matlab function dsearchn.
Most of the results look ok but there are some werid ones highlighted in red below that don’t seem right. Some there appears to be a closer point than the one selected and one that doesn’t seem to have a field point anywhere near it.
Questions
Am I using this function correctly?
Can anyone explain why the oddball "nearest points"?
What could be done to fix this?
Is there an alternative function or method to acheive the result I am aiming for?
NearestPoint = dsearchn([X(:),Y(:)],[TransectDataStats.Easting,TransectDataStats.Northing])
figure
plot(X(:),Y(:),’o’)
hold on
plot(X(NearestPoint),Y(NearestPoint),’.’)
plot(TransectDataStats.Easting,TransectDataStats.Northing,’x’)
axis equal
size(X)
ans =
2895 921
size(TransectDataStats.Easting)
ans =
654 1I am trying to compare field data with classified sattellite imagery.
What I am aiming for is to find the nearest pixel in the sattellite image to the location of the field data.
The coordinates of the pixels are in X & Y represented by blue circles below, spacing is 30m x 30m.
The coordinates of the field data is in TransectDataStats.Easting & .Northing represented by "x’s" below.
The dots are the "closest point" as determined by the matlab function dsearchn.
Most of the results look ok but there are some werid ones highlighted in red below that don’t seem right. Some there appears to be a closer point than the one selected and one that doesn’t seem to have a field point anywhere near it.
Questions
Am I using this function correctly?
Can anyone explain why the oddball "nearest points"?
What could be done to fix this?
Is there an alternative function or method to acheive the result I am aiming for?
NearestPoint = dsearchn([X(:),Y(:)],[TransectDataStats.Easting,TransectDataStats.Northing])
figure
plot(X(:),Y(:),’o’)
hold on
plot(X(NearestPoint),Y(NearestPoint),’.’)
plot(TransectDataStats.Easting,TransectDataStats.Northing,’x’)
axis equal
size(X)
ans =
2895 921
size(TransectDataStats.Easting)
ans =
654 1 I am trying to compare field data with classified sattellite imagery.
What I am aiming for is to find the nearest pixel in the sattellite image to the location of the field data.
The coordinates of the pixels are in X & Y represented by blue circles below, spacing is 30m x 30m.
The coordinates of the field data is in TransectDataStats.Easting & .Northing represented by "x’s" below.
The dots are the "closest point" as determined by the matlab function dsearchn.
Most of the results look ok but there are some werid ones highlighted in red below that don’t seem right. Some there appears to be a closer point than the one selected and one that doesn’t seem to have a field point anywhere near it.
Questions
Am I using this function correctly?
Can anyone explain why the oddball "nearest points"?
What could be done to fix this?
Is there an alternative function or method to acheive the result I am aiming for?
NearestPoint = dsearchn([X(:),Y(:)],[TransectDataStats.Easting,TransectDataStats.Northing])
figure
plot(X(:),Y(:),’o’)
hold on
plot(X(NearestPoint),Y(NearestPoint),’.’)
plot(TransectDataStats.Easting,TransectDataStats.Northing,’x’)
axis equal
size(X)
ans =
2895 921
size(TransectDataStats.Easting)
ans =
654 1 dsearchn, satellite imagery, closest pixel, image processing MATLAB Answers — New Questions
How can I find the coefficients of the 2D interpolated function?
My function is . I used following code to interpolation. How can I find the coefficients of the interpolated function ?
Eta = load(‘Eta.txt’);
t = 0:5:(8.25*60); % time
x = [0,3750,7500,8000]; % distance
[X,T] = meshgrid(x,t);
% interpolation
[xq,tq] = meshgrid(0:2:8000,0:(8.25*60)) ;
Eta_intp = interp2(X,T,eta,xq,tq,’spline’);My function is . I used following code to interpolation. How can I find the coefficients of the interpolated function ?
Eta = load(‘Eta.txt’);
t = 0:5:(8.25*60); % time
x = [0,3750,7500,8000]; % distance
[X,T] = meshgrid(x,t);
% interpolation
[xq,tq] = meshgrid(0:2:8000,0:(8.25*60)) ;
Eta_intp = interp2(X,T,eta,xq,tq,’spline’); My function is . I used following code to interpolation. How can I find the coefficients of the interpolated function ?
Eta = load(‘Eta.txt’);
t = 0:5:(8.25*60); % time
x = [0,3750,7500,8000]; % distance
[X,T] = meshgrid(x,t);
% interpolation
[xq,tq] = meshgrid(0:2:8000,0:(8.25*60)) ;
Eta_intp = interp2(X,T,eta,xq,tq,’spline’); 2d interpolation MATLAB Answers — New Questions
Unfamiliar error message from ode45: “Unrecognized function or variable ‘packageAsFuncHandle”.
One of my students is receiving this message when trying to run ode45 from her computer. Running the exact same script on another machine does not throw an error. I’ve had her uninstall and reinstall MATLAB but getting the same results. Has anyone else experienced this? Haven’t seen it anywhere else on the forum/community. Thanks!One of my students is receiving this message when trying to run ode45 from her computer. Running the exact same script on another machine does not throw an error. I’ve had her uninstall and reinstall MATLAB but getting the same results. Has anyone else experienced this? Haven’t seen it anywhere else on the forum/community. Thanks! One of my students is receiving this message when trying to run ode45 from her computer. Running the exact same script on another machine does not throw an error. I’ve had her uninstall and reinstall MATLAB but getting the same results. Has anyone else experienced this? Haven’t seen it anywhere else on the forum/community. Thanks! ode45, function MATLAB Answers — New Questions
Detect a collision between 2 robotPlatform
Hello,
I imported 2 URDF files using the importrobot function. Then, I created a robotScenario by adding a robotPlatform for each robot. I want to check during the scenario that there are no collisions between the robots.
I tried using the checkCollision function between the 2 robotPlatforms, but this function does not accept non-rigidBodyTree-based platforms.
Then, I tried to create a robotPlatform ‘hand’ from an STL file and attach ‘hand’ to the ‘robot2Scn’ platform using the attach function, but the position of ‘hand’ does not update when I use the checkCollision(robotScn, ‘hand’, IgnoreSelfCollision="on") function. This function returns 1 when ‘robotScn’ is at the initial position of ‘hand’, otherwise it returns 0.
Is there a function or have you a suggestion to check for collisions between 2 robotPlatforms in a robotScenario?
Thank you.
robot = importrobot("robot.urdf");
robot2 = importrobot("robot_2.urdf");
scenario = robotScenario(UpdateRate=1,StopTime=10);
robotScn = robotPlatform("robot1",scenario,RigidBodyTree=robot);
robotScn2 = robotPlatform("robot2",scenario,RigidBodyTree=robot2);
% Trying to manually add a collision zone (Test with and without using clearCollision on robot2)
stlData = stlread(‘hand_link.stl’);
vertices = stlData.Points;
faces = stlData.ConnectivityList;
handMesh = collisionMesh(vertices);
base = robotPlatform("hand",scenario,Collision=handMesh, initialBasePosition[0.2 0.2 0.2]);
attach(robotScn2,"hand","hand_link",ChildToParentTransform=trvec2tform([0 0 0]))
checkCollision(robotScn,"hand", IgnoreSelfCollision="on")Hello,
I imported 2 URDF files using the importrobot function. Then, I created a robotScenario by adding a robotPlatform for each robot. I want to check during the scenario that there are no collisions between the robots.
I tried using the checkCollision function between the 2 robotPlatforms, but this function does not accept non-rigidBodyTree-based platforms.
Then, I tried to create a robotPlatform ‘hand’ from an STL file and attach ‘hand’ to the ‘robot2Scn’ platform using the attach function, but the position of ‘hand’ does not update when I use the checkCollision(robotScn, ‘hand’, IgnoreSelfCollision="on") function. This function returns 1 when ‘robotScn’ is at the initial position of ‘hand’, otherwise it returns 0.
Is there a function or have you a suggestion to check for collisions between 2 robotPlatforms in a robotScenario?
Thank you.
robot = importrobot("robot.urdf");
robot2 = importrobot("robot_2.urdf");
scenario = robotScenario(UpdateRate=1,StopTime=10);
robotScn = robotPlatform("robot1",scenario,RigidBodyTree=robot);
robotScn2 = robotPlatform("robot2",scenario,RigidBodyTree=robot2);
% Trying to manually add a collision zone (Test with and without using clearCollision on robot2)
stlData = stlread(‘hand_link.stl’);
vertices = stlData.Points;
faces = stlData.ConnectivityList;
handMesh = collisionMesh(vertices);
base = robotPlatform("hand",scenario,Collision=handMesh, initialBasePosition[0.2 0.2 0.2]);
attach(robotScn2,"hand","hand_link",ChildToParentTransform=trvec2tform([0 0 0]))
checkCollision(robotScn,"hand", IgnoreSelfCollision="on") Hello,
I imported 2 URDF files using the importrobot function. Then, I created a robotScenario by adding a robotPlatform for each robot. I want to check during the scenario that there are no collisions between the robots.
I tried using the checkCollision function between the 2 robotPlatforms, but this function does not accept non-rigidBodyTree-based platforms.
Then, I tried to create a robotPlatform ‘hand’ from an STL file and attach ‘hand’ to the ‘robot2Scn’ platform using the attach function, but the position of ‘hand’ does not update when I use the checkCollision(robotScn, ‘hand’, IgnoreSelfCollision="on") function. This function returns 1 when ‘robotScn’ is at the initial position of ‘hand’, otherwise it returns 0.
Is there a function or have you a suggestion to check for collisions between 2 robotPlatforms in a robotScenario?
Thank you.
robot = importrobot("robot.urdf");
robot2 = importrobot("robot_2.urdf");
scenario = robotScenario(UpdateRate=1,StopTime=10);
robotScn = robotPlatform("robot1",scenario,RigidBodyTree=robot);
robotScn2 = robotPlatform("robot2",scenario,RigidBodyTree=robot2);
% Trying to manually add a collision zone (Test with and without using clearCollision on robot2)
stlData = stlread(‘hand_link.stl’);
vertices = stlData.Points;
faces = stlData.ConnectivityList;
handMesh = collisionMesh(vertices);
base = robotPlatform("hand",scenario,Collision=handMesh, initialBasePosition[0.2 0.2 0.2]);
attach(robotScn2,"hand","hand_link",ChildToParentTransform=trvec2tform([0 0 0]))
checkCollision(robotScn,"hand", IgnoreSelfCollision="on") robotics, collision MATLAB Answers — New Questions
Call Simulink Function That is Defined in a Separate Model Using MATLAB Function Block and Model Reference
I have a MATLAB Function block created inside the Model A which call y = Test(u) Simulink Function. And another model called Model B in which Simulink Function y = Test(u) is implemented in.
Now in a seperate model called Simulation I have use two Model block to reference to Model A and Model B, when I update the model an error observed which reference to Model A and say that the Test funciton is undefined.
My question is: Is that possible to call a Simulink Function from a MATLAB Function block that are both implemented in a sepearte model?I have a MATLAB Function block created inside the Model A which call y = Test(u) Simulink Function. And another model called Model B in which Simulink Function y = Test(u) is implemented in.
Now in a seperate model called Simulation I have use two Model block to reference to Model A and Model B, when I update the model an error observed which reference to Model A and say that the Test funciton is undefined.
My question is: Is that possible to call a Simulink Function from a MATLAB Function block that are both implemented in a sepearte model? I have a MATLAB Function block created inside the Model A which call y = Test(u) Simulink Function. And another model called Model B in which Simulink Function y = Test(u) is implemented in.
Now in a seperate model called Simulation I have use two Model block to reference to Model A and Model B, when I update the model an error observed which reference to Model A and say that the Test funciton is undefined.
My question is: Is that possible to call a Simulink Function from a MATLAB Function block that are both implemented in a sepearte model? simulinkfunction, matlabfunction, simulink, functionconnector MATLAB Answers — New Questions
Why does this technique not work?
I have a mat file which has a row vector u and a matrix temp_gbo. The size of this matrix is 100 x 4. I want the following:
Each row of the matrix temp_gbo must have the same arrangment of elements as is in u.The mat file and the script "swapping" are attached but the script doesn’t fulfill my requirement. How should I modify this code?I have a mat file which has a row vector u and a matrix temp_gbo. The size of this matrix is 100 x 4. I want the following:
Each row of the matrix temp_gbo must have the same arrangment of elements as is in u.The mat file and the script "swapping" are attached but the script doesn’t fulfill my requirement. How should I modify this code? I have a mat file which has a row vector u and a matrix temp_gbo. The size of this matrix is 100 x 4. I want the following:
Each row of the matrix temp_gbo must have the same arrangment of elements as is in u.The mat file and the script "swapping" are attached but the script doesn’t fulfill my requirement. How should I modify this code? arrangement of elements, row vector, matrix, swapping MATLAB Answers — New Questions
CLA NON-REUSABLE CODE GENERATION
I want to generate non-reusable CLA code and use it in my project. This code needs to integrate in CCS workspace where the issue is when i use non-reusable method for code generation the CLA task is not triggerd.I want to generate non-reusable CLA code and use it in my project. This code needs to integrate in CCS workspace where the issue is when i use non-reusable method for code generation the CLA task is not triggerd. I want to generate non-reusable CLA code and use it in my project. This code needs to integrate in CCS workspace where the issue is when i use non-reusable method for code generation the CLA task is not triggerd. matlab MATLAB Answers — New Questions
What comes after sorting eigenvalues in PCA?
I’m a student, I have to build PCA from scratch using Matlab on iris data.
Iris data have 4 features i want to reduce them to 2.
I reached the sorting of eigenvalues step. What is the next step?I’m a student, I have to build PCA from scratch using Matlab on iris data.
Iris data have 4 features i want to reduce them to 2.
I reached the sorting of eigenvalues step. What is the next step? I’m a student, I have to build PCA from scratch using Matlab on iris data.
Iris data have 4 features i want to reduce them to 2.
I reached the sorting of eigenvalues step. What is the next step? pca, features reduction MATLAB Answers — New Questions
About time-frequency analysis
I am having trouble understanding how the time width of the Kaiser window is determined from each parameter used in "pspectrum" for time-frequency analysis. Currently, I am using the code below:
pspectrum(W_mix,Fs,’spectrogram’,’FrequencyLimits’,[0 1.2e6],
‘FrequencyResolution’,9e4,’Overlap’,99,’Leakage’,0.75,’MinThreshold’,-95);
Here, w_mix is a waveform data of size 1×15000, and Fs is the sampling frequency, which is 1×10^8. I understand that the shape factor βbetaβ is 10 in this case, but how is the time width of the window function determined? According to the previous research I am referring to, the time width is supposed to be 20.52 μs, but I do not understand the calculation method. Could you please explain it to me?I am having trouble understanding how the time width of the Kaiser window is determined from each parameter used in "pspectrum" for time-frequency analysis. Currently, I am using the code below:
pspectrum(W_mix,Fs,’spectrogram’,’FrequencyLimits’,[0 1.2e6],
‘FrequencyResolution’,9e4,’Overlap’,99,’Leakage’,0.75,’MinThreshold’,-95);
Here, w_mix is a waveform data of size 1×15000, and Fs is the sampling frequency, which is 1×10^8. I understand that the shape factor βbetaβ is 10 in this case, but how is the time width of the window function determined? According to the previous research I am referring to, the time width is supposed to be 20.52 μs, but I do not understand the calculation method. Could you please explain it to me? I am having trouble understanding how the time width of the Kaiser window is determined from each parameter used in "pspectrum" for time-frequency analysis. Currently, I am using the code below:
pspectrum(W_mix,Fs,’spectrogram’,’FrequencyLimits’,[0 1.2e6],
‘FrequencyResolution’,9e4,’Overlap’,99,’Leakage’,0.75,’MinThreshold’,-95);
Here, w_mix is a waveform data of size 1×15000, and Fs is the sampling frequency, which is 1×10^8. I understand that the shape factor βbetaβ is 10 in this case, but how is the time width of the window function determined? According to the previous research I am referring to, the time width is supposed to be 20.52 μs, but I do not understand the calculation method. Could you please explain it to me? #time-frecuency analysis MATLAB Answers — New Questions
Logarithmic trendline equation of data
Hello eveyone,
I try to get a trendline equation of data. This equation must be like "e^x". How can i do that. are there any tools?
Thanks
CemHello eveyone,
I try to get a trendline equation of data. This equation must be like "e^x". How can i do that. are there any tools?
Thanks
Cem Hello eveyone,
I try to get a trendline equation of data. This equation must be like "e^x". How can i do that. are there any tools?
Thanks
Cem trendline, equation MATLAB Answers — New Questions
Way of Calculating NPCR and UACI
Can someone clear the way to calculate NPCR and UACI as some suggests to change one or more bits of each pixel value in image while otther prefers to change single pixel value in whole image and also some do by a change of single bit in key, Which is the correct way to evaluate these values?Can someone clear the way to calculate NPCR and UACI as some suggests to change one or more bits of each pixel value in image while otther prefers to change single pixel value in whole image and also some do by a change of single bit in key, Which is the correct way to evaluate these values? Can someone clear the way to calculate NPCR and UACI as some suggests to change one or more bits of each pixel value in image while otther prefers to change single pixel value in whole image and also some do by a change of single bit in key, Which is the correct way to evaluate these values? image processing, npcr, uaci, matlab MATLAB Answers — New Questions
What is the port compatibility for Simscape blocks?
Hi,
Whenever I work with simscape, I have this issue. Where is the port compatability defined?? I couldnt find any documentation related to this.
Some of the simscpae blocks are not connectable to any other directly in Simulink. Also, the PS-Simulink converter doesnt help
Here(in the fig), you can see that the A port is not connecting to anything. I tried to use all possible ways. My main aim is to connect scope to it and check the waveform. But its not connecting simply. I tried using a voltage sensor, which is a simscape element. But still its not connecting.
Ps: its not the issue of input ports or output ports. The conservative ports ABC in the above image are output ports of the block.Hi,
Whenever I work with simscape, I have this issue. Where is the port compatability defined?? I couldnt find any documentation related to this.
Some of the simscpae blocks are not connectable to any other directly in Simulink. Also, the PS-Simulink converter doesnt help
Here(in the fig), you can see that the A port is not connecting to anything. I tried to use all possible ways. My main aim is to connect scope to it and check the waveform. But its not connecting simply. I tried using a voltage sensor, which is a simscape element. But still its not connecting.
Ps: its not the issue of input ports or output ports. The conservative ports ABC in the above image are output ports of the block. Hi,
Whenever I work with simscape, I have this issue. Where is the port compatability defined?? I couldnt find any documentation related to this.
Some of the simscpae blocks are not connectable to any other directly in Simulink. Also, the PS-Simulink converter doesnt help
Here(in the fig), you can see that the A port is not connecting to anything. I tried to use all possible ways. My main aim is to connect scope to it and check the waveform. But its not connecting simply. I tried using a voltage sensor, which is a simscape element. But still its not connecting.
Ps: its not the issue of input ports or output ports. The conservative ports ABC in the above image are output ports of the block. simscape, simulink, input, output MATLAB Answers — New Questions
How to control the generation of fixed points within a fixed period of 1ms and gradually generate points (waveforms) according to the progress of the period (time)?
I generated the code for the model using a C coder, and for real-time performance, I want to push it forward every 1ms. During this 1ms cycle, there are some other tasks that need to be completed in addition to the points that should be generated based on the step size. Therefore, I do not want to simply push the waveform generation based on the step size, as this will result in new points coming before I have finished reading and writing, which may miss or overwrite these points. This is something I do not want to happen.I generated the code for the model using a C coder, and for real-time performance, I want to push it forward every 1ms. During this 1ms cycle, there are some other tasks that need to be completed in addition to the points that should be generated based on the step size. Therefore, I do not want to simply push the waveform generation based on the step size, as this will result in new points coming before I have finished reading and writing, which may miss or overwrite these points. This is something I do not want to happen. I generated the code for the model using a C coder, and for real-time performance, I want to push it forward every 1ms. During this 1ms cycle, there are some other tasks that need to be completed in addition to the points that should be generated based on the step size. Therefore, I do not want to simply push the waveform generation based on the step size, as this will result in new points coming before I have finished reading and writing, which may miss or overwrite these points. This is something I do not want to happen. simulink, embedded coder MATLAB Answers — New Questions
Visualization volume data like pcolor3
Basically I was looking for a pcolor3 like function that can run in newer version of matlab. The idea of using slice to have multiple section and tune the alpha value does not work in new version. The issue is that only the front slice is shown and the slices behind are blocked. Is there a way to solve this?
I was looking for a function that could possibly produce some figure like below. Thanks a lot!
<</matlabcentral/answers/uploaded_files/128402/screenshot.jpg.png>>Basically I was looking for a pcolor3 like function that can run in newer version of matlab. The idea of using slice to have multiple section and tune the alpha value does not work in new version. The issue is that only the front slice is shown and the slices behind are blocked. Is there a way to solve this?
I was looking for a function that could possibly produce some figure like below. Thanks a lot!
<</matlabcentral/answers/uploaded_files/128402/screenshot.jpg.png>> Basically I was looking for a pcolor3 like function that can run in newer version of matlab. The idea of using slice to have multiple section and tune the alpha value does not work in new version. The issue is that only the front slice is shown and the slices behind are blocked. Is there a way to solve this?
I was looking for a function that could possibly produce some figure like below. Thanks a lot!
<</matlabcentral/answers/uploaded_files/128402/screenshot.jpg.png>> visualization, 3d, pcolor3, pcolor MATLAB Answers — New Questions
append (not strcat) to combine strings with whitespace (n)
I have a text box (text edit field, shoud it be a label box?)
I want to add lines of text to it without loosing the old text.
app.DebugField.Value = append(app.DebugField.Value, "rew LBn");
but the newlines are showing up as text n
Start Trials at 22:26:09 >> rew LBn
I guess I have to sprintf() the string first but why can’t n be properly interpreted by string handling functions?I have a text box (text edit field, shoud it be a label box?)
I want to add lines of text to it without loosing the old text.
app.DebugField.Value = append(app.DebugField.Value, "rew LBn");
but the newlines are showing up as text n
Start Trials at 22:26:09 >> rew LBn
I guess I have to sprintf() the string first but why can’t n be properly interpreted by string handling functions? I have a text box (text edit field, shoud it be a label box?)
I want to add lines of text to it without loosing the old text.
app.DebugField.Value = append(app.DebugField.Value, "rew LBn");
but the newlines are showing up as text n
Start Trials at 22:26:09 >> rew LBn
I guess I have to sprintf() the string first but why can’t n be properly interpreted by string handling functions? n in strings MATLAB Answers — New Questions
Both Pcolor color plot and quiver plot in log scale
Hai,
I need to plot pcolor plot with y-axis in log scale and over plot with quiver plot in log scale.
Please help me how to do this.
Here is my code:
pcolor(1:365,pr(:,1),Ez1.*10^6);shading interp; colormap(‘jet(25)’);colorbar;set(gca,’YScale’,’log’);
hold on ; quiverInLogScale(1:15:365,MP,Zu1(:,1:15:365),Zv1(:,1:15:365))%,2,’-k’)
set(gca,’Ydir’,’reverse’);
caxis([0 8]);
ylim([1 100]);%xlim([0 396]);
title(‘(a) Daily mean (2005:2021) H2O (ppmv)’)
set(gca, ‘XTick’, [1 31 59 90 120 151 181 212 243 273 304 335 365]);
set(gca,’XTickLabel’, {‘1′ ’31’ ’59’ ’90’ ‘120’ ‘151’ ‘181’ ‘212’ ‘243’ ‘273’ ‘304’ ‘335’ ‘365’})
ylabel(‘P (hPa)’)
set(gca, ‘YTick’, [1 10 21.54 31.62 56.23 100]);
set(gca,’YTickLabel’, {‘1′, ’10’,’21.54′,’31.62′,’56.23′,’100′})
colormap(ax1,jet(20)), colorbarHai,
I need to plot pcolor plot with y-axis in log scale and over plot with quiver plot in log scale.
Please help me how to do this.
Here is my code:
pcolor(1:365,pr(:,1),Ez1.*10^6);shading interp; colormap(‘jet(25)’);colorbar;set(gca,’YScale’,’log’);
hold on ; quiverInLogScale(1:15:365,MP,Zu1(:,1:15:365),Zv1(:,1:15:365))%,2,’-k’)
set(gca,’Ydir’,’reverse’);
caxis([0 8]);
ylim([1 100]);%xlim([0 396]);
title(‘(a) Daily mean (2005:2021) H2O (ppmv)’)
set(gca, ‘XTick’, [1 31 59 90 120 151 181 212 243 273 304 335 365]);
set(gca,’XTickLabel’, {‘1′ ’31’ ’59’ ’90’ ‘120’ ‘151’ ‘181’ ‘212’ ‘243’ ‘273’ ‘304’ ‘335’ ‘365’})
ylabel(‘P (hPa)’)
set(gca, ‘YTick’, [1 10 21.54 31.62 56.23 100]);
set(gca,’YTickLabel’, {‘1′, ’10’,’21.54′,’31.62′,’56.23′,’100′})
colormap(ax1,jet(20)), colorbar Hai,
I need to plot pcolor plot with y-axis in log scale and over plot with quiver plot in log scale.
Please help me how to do this.
Here is my code:
pcolor(1:365,pr(:,1),Ez1.*10^6);shading interp; colormap(‘jet(25)’);colorbar;set(gca,’YScale’,’log’);
hold on ; quiverInLogScale(1:15:365,MP,Zu1(:,1:15:365),Zv1(:,1:15:365))%,2,’-k’)
set(gca,’Ydir’,’reverse’);
caxis([0 8]);
ylim([1 100]);%xlim([0 396]);
title(‘(a) Daily mean (2005:2021) H2O (ppmv)’)
set(gca, ‘XTick’, [1 31 59 90 120 151 181 212 243 273 304 335 365]);
set(gca,’XTickLabel’, {‘1′ ’31’ ’59’ ’90’ ‘120’ ‘151’ ‘181’ ‘212’ ‘243’ ‘273’ ‘304’ ‘335’ ‘365’})
ylabel(‘P (hPa)’)
set(gca, ‘YTick’, [1 10 21.54 31.62 56.23 100]);
set(gca,’YTickLabel’, {‘1′, ’10’,’21.54′,’31.62′,’56.23′,’100′})
colormap(ax1,jet(20)), colorbar pcolor plot, quiver plot, logscale MATLAB Answers — New Questions