Month: July 2024
How do I synchronize PTP clocks between two Speedgoat target computers?
Can you give me an example for clock synchronization between two Speedgoat target computers using PTP?Can you give me an example for clock synchronization between two Speedgoat target computers using PTP? Can you give me an example for clock synchronization between two Speedgoat target computers using PTP? slrt, ptp, speedgoat, sync MATLAB Answers — New Questions
Retrieving Arrays Within Set of Matrices
Hello,
I have several sets of data that I want to plot on one graph. The problem is that each data set is in its own matrix. For instance, I have a 36×4 matrix (let’s call it M). In each of the cells in the 4th column is a 516×2 matrix, corresponding to x and y values. The x values are the same for each of the 516×2 matricies, so I just want to plot the y values against one set of x values. I try to make an additional matrix (let’s call it N) to have the y values all side by side by using the following code
N=[M{:,4}(:,2)]
But then I get the following error
Intermediate brace ‘{}’ indexing produced a comma-separated list with 36 values, but it must produce a single value when followed by subsequent indexing operations.
The end goal is to be able to use this after iterative peak fitting across multiple similar data sets, but I need to be able to efficiently visualize the resulting plots. I would be grateful for any help on this. Thank you!Hello,
I have several sets of data that I want to plot on one graph. The problem is that each data set is in its own matrix. For instance, I have a 36×4 matrix (let’s call it M). In each of the cells in the 4th column is a 516×2 matrix, corresponding to x and y values. The x values are the same for each of the 516×2 matricies, so I just want to plot the y values against one set of x values. I try to make an additional matrix (let’s call it N) to have the y values all side by side by using the following code
N=[M{:,4}(:,2)]
But then I get the following error
Intermediate brace ‘{}’ indexing produced a comma-separated list with 36 values, but it must produce a single value when followed by subsequent indexing operations.
The end goal is to be able to use this after iterative peak fitting across multiple similar data sets, but I need to be able to efficiently visualize the resulting plots. I would be grateful for any help on this. Thank you! Hello,
I have several sets of data that I want to plot on one graph. The problem is that each data set is in its own matrix. For instance, I have a 36×4 matrix (let’s call it M). In each of the cells in the 4th column is a 516×2 matrix, corresponding to x and y values. The x values are the same for each of the 516×2 matricies, so I just want to plot the y values against one set of x values. I try to make an additional matrix (let’s call it N) to have the y values all side by side by using the following code
N=[M{:,4}(:,2)]
But then I get the following error
Intermediate brace ‘{}’ indexing produced a comma-separated list with 36 values, but it must produce a single value when followed by subsequent indexing operations.
The end goal is to be able to use this after iterative peak fitting across multiple similar data sets, but I need to be able to efficiently visualize the resulting plots. I would be grateful for any help on this. Thank you! matrix MATLAB Answers — New Questions
Feedback: Please Include Customer Identifying Info In Booking Email
The emails we get from the Bookings have no customer identifying info.
It has their name, assigned staff member, and the date & time etc., but that’s it.
So we have to go in to Bookings just to get their email*, copy it, and manually paste it elsewhere (Freshdesk).
It’s such a waste of time for something that should be included.
Please consider adding it as an option!
(*Sometimes we use their mobile if we can’t find customer using their email.)
The emails we get from the Bookings have no customer identifying info. It has their name, assigned staff member, and the date & time etc., but that’s it. So we have to go in to Bookings just to get their email*, copy it, and manually paste it elsewhere (Freshdesk). It’s such a waste of time for something that should be included. Please consider adding it as an option! (*Sometimes we use their mobile if we can’t find customer using their email.) Read More
How to create a 3D world and simulate a virtual camera in MATLAB on MacOS?
Hello,
I need to create a 3D world given a 3D model (STL, OBJ, etc.) and simulate a virtual camera in MATLAB.
The goal is to create a synthetic dataset where it contains image frames from the virtual camera inside the scene. The user would provide the intrinsics and the poses for the virtual camera.
I’m currently researching if MATLAB has this capability and I have found the following:
https://www.mathworks.com/help/driving/ref/simulation3dcamera.html
I think this would work well except that Simulink 3D is not supported on Mac, so I don’t have this option.
I have found the following link below which is very similar to what I need, but I’m having some trouble finding options to specify camera intrinsics to the view. It’s possible to provide intrinsics in a view?
https://www.mathworks.com/help/matlab/creating_plots/example-moving-the-camera-through-a-scene.html
Does anyone has any other ideas?
Thank you!Hello,
I need to create a 3D world given a 3D model (STL, OBJ, etc.) and simulate a virtual camera in MATLAB.
The goal is to create a synthetic dataset where it contains image frames from the virtual camera inside the scene. The user would provide the intrinsics and the poses for the virtual camera.
I’m currently researching if MATLAB has this capability and I have found the following:
https://www.mathworks.com/help/driving/ref/simulation3dcamera.html
I think this would work well except that Simulink 3D is not supported on Mac, so I don’t have this option.
I have found the following link below which is very similar to what I need, but I’m having some trouble finding options to specify camera intrinsics to the view. It’s possible to provide intrinsics in a view?
https://www.mathworks.com/help/matlab/creating_plots/example-moving-the-camera-through-a-scene.html
Does anyone has any other ideas?
Thank you! Hello,
I need to create a 3D world given a 3D model (STL, OBJ, etc.) and simulate a virtual camera in MATLAB.
The goal is to create a synthetic dataset where it contains image frames from the virtual camera inside the scene. The user would provide the intrinsics and the poses for the virtual camera.
I’m currently researching if MATLAB has this capability and I have found the following:
https://www.mathworks.com/help/driving/ref/simulation3dcamera.html
I think this would work well except that Simulink 3D is not supported on Mac, so I don’t have this option.
I have found the following link below which is very similar to what I need, but I’m having some trouble finding options to specify camera intrinsics to the view. It’s possible to provide intrinsics in a view?
https://www.mathworks.com/help/matlab/creating_plots/example-moving-the-camera-through-a-scene.html
Does anyone has any other ideas?
Thank you! image, camera, 3d, views MATLAB Answers — New Questions
determine order of results in search on sharepoint site
Currently when a user searches for a document on our sharepoint site, it doesnt show the results in order of latest modified or created date. How can we organise our search to show the results in order from latest modified date?
Currently when a user searches for a document on our sharepoint site, it doesnt show the results in order of latest modified or created date. How can we organise our search to show the results in order from latest modified date? Read More
SimMechanics Link Problem
I am trying to import a Solidowrks assembly into simMechanics. I followed all the steps as in the web site. I have the pull-down menu SinMechanics Link in SolidWorks. When I try to save the assembly in the xml format, I get this error:
Could not start MATLAB. Check your MATLAB installation. Consult documentation to identify possible causes of failure.
I get this error regarding Matlab is open or not.
Note: I am using Matlab 2010a and SolidWorks 2010I am trying to import a Solidowrks assembly into simMechanics. I followed all the steps as in the web site. I have the pull-down menu SinMechanics Link in SolidWorks. When I try to save the assembly in the xml format, I get this error:
Could not start MATLAB. Check your MATLAB installation. Consult documentation to identify possible causes of failure.
I get this error regarding Matlab is open or not.
Note: I am using Matlab 2010a and SolidWorks 2010 I am trying to import a Solidowrks assembly into simMechanics. I followed all the steps as in the web site. I have the pull-down menu SinMechanics Link in SolidWorks. When I try to save the assembly in the xml format, I get this error:
Could not start MATLAB. Check your MATLAB installation. Consult documentation to identify possible causes of failure.
I get this error regarding Matlab is open or not.
Note: I am using Matlab 2010a and SolidWorks 2010 solidworks, r2010a MATLAB Answers — New Questions
Assista ao vídeo da palestra “Inteligência Artificial & Educação: é possível as duas serem aliadas?”
Feliz em começar aqui nossos posts semanais com os conteúdos do evento AI for ChangeMakers
E o primeiro é sobre IA na educação com Vera Cabral (Diretora de Educação na Microsoft LATAM) e
Ana Ligia Scaccheti (Diretora-executiva na Associação Nova Escola)
https://www.youtube.com/watch?v=HFsXiNkdXmA&feature=youtu.be
Feliz em começar aqui nossos posts semanais com os conteúdos do evento AI for ChangeMakers
E o primeiro é sobre IA na educação com Vera Cabral (Diretora de Educação na Microsoft LATAM) e Ana Ligia Scaccheti (Diretora-executiva na Associação Nova Escola)
https://www.youtube.com/watch?v=HFsXiNkdXmA&feature=youtu.be Read More
Flagged emails cant be changed in To-Do
When I flag an email in Outlook, it shows up in the To-Do list but I cannot enter a due date or status (or probably anything else). What’s up with that?
When I flag an email in Outlook, it shows up in the To-Do list but I cannot enter a due date or status (or probably anything else). What’s up with that? Read More
Is there a way to disable this?
I don’t manipulate my figures any, so I don’t need whatever toolbar this is. Also, it’s causing MATLAB to generate strange errors, which are annoying but don’t actually mean anything important for my program. I’m looking for a way to generate static figures (figures that cannot be panned, zoomed, etc) or at least disabling this toolbar when creating your normal bar graphs.I don’t manipulate my figures any, so I don’t need whatever toolbar this is. Also, it’s causing MATLAB to generate strange errors, which are annoying but don’t actually mean anything important for my program. I’m looking for a way to generate static figures (figures that cannot be panned, zoomed, etc) or at least disabling this toolbar when creating your normal bar graphs. I don’t manipulate my figures any, so I don’t need whatever toolbar this is. Also, it’s causing MATLAB to generate strange errors, which are annoying but don’t actually mean anything important for my program. I’m looking for a way to generate static figures (figures that cannot be panned, zoomed, etc) or at least disabling this toolbar when creating your normal bar graphs. matlab, figure MATLAB Answers — New Questions
SharePoint Global Navigation Blank
I am struggling with getting the Global navigation working, not sure if I am doing something wrong or if it’s a timing issue?
I have read many MS and other pages and videos on Navigation and hub sites and think I understand it a bit but clearly, I am missing something.
Steps Taken
Via SharePoint Admin & Site Settings & PowerShell
Created a Comm site (HomeSite)Set as the Home site, via PS [Set-SPOHomeSite -HomeSiteUrl https://…]Registered the HomeSite to a Hub siteChanged the “look and feel” on the HomeSite, eg theme colors, layoutThe Global Navigation link is shown under the site’s Settings menu with;Enable global nav “On” changed custom logo for visual testing (and is shown on all pages now)Confirmed Hub Settings is “Shown in navigation”Associated another site (Site2), with the HomeSite Created two more Comms sites (HrDeptHub) & (Onboarding)Associated Onboarding to the HrDeptHub siteAdded a parent association to the HrDeptHub to the HomeSiteasdf
But in the end, I am not seeing any menu changes (horizontal page menus on the Comms site) and the Global Navigation is empty. I am logged into the site as the Site Owner and have a test user with basic permissions only.
Oddly the Theme settings/colors on the HomeSite (hub) are not propagating to the associated sites. In another test with 2 brand new sites (CommSite1 hub) & (Teamsite1), branding/colors are enforced on the associated TeamSite1. But I the Global Nav is empty, and the top Hub navigation (horizontal) only shows items from the site itself.
I am struggling with getting the Global navigation working, not sure if I am doing something wrong or if it’s a timing issue?I have read many MS and other pages and videos on Navigation and hub sites and think I understand it a bit but clearly, I am missing something. Steps TakenVia SharePoint Admin & Site Settings & PowerShellCreated a Comm site (HomeSite)Set as the Home site, via PS [Set-SPOHomeSite -HomeSiteUrl https://…]Registered the HomeSite to a Hub siteChanged the “look and feel” on the HomeSite, eg theme colors, layoutThe Global Navigation link is shown under the site’s Settings menu with;Enable global nav “On” changed custom logo for visual testing (and is shown on all pages now)Confirmed Hub Settings is “Shown in navigation”Associated another site (Site2), with the HomeSite Created two more Comms sites (HrDeptHub) & (Onboarding)Associated Onboarding to the HrDeptHub siteAdded a parent association to the HrDeptHub to the HomeSiteasdf But in the end, I am not seeing any menu changes (horizontal page menus on the Comms site) and the Global Navigation is empty. I am logged into the site as the Site Owner and have a test user with basic permissions only. Oddly the Theme settings/colors on the HomeSite (hub) are not propagating to the associated sites. In another test with 2 brand new sites (CommSite1 hub) & (Teamsite1), branding/colors are enforced on the associated TeamSite1. But I the Global Nav is empty, and the top Hub navigation (horizontal) only shows items from the site itself. Read More
SharePoint form “Edit Columns” with “Conditional Formula” and available field properties
I am trying to find out where I can find a complete list of the available “properties” of a column, so I don’t have to continually ask in a forum.
For example, I am trying to set a “conditional formula” to show a column on the default New Experience forms when the current user a specific person (people column-single input).
eg
=if([$CurrentUser.email] == ‘name @ domain dot com’, ‘true’, ‘false’)
What are the right properties and where can I find the list for this or any column for that matter, so can learn to solve these questions on my own.
AND
Similarly the correct syntax/properties to use for say a people column, MS help shows this,
=if([$Owner.email] == ‘name @ domain dot com’, ‘true’, ‘false’)
I assume “Owner.email” is the created by person’s email but that is not working when I change it to local user/email.
Thanks for any direction, suggestions.
I am trying to find out where I can find a complete list of the available “properties” of a column, so I don’t have to continually ask in a forum. For example, I am trying to set a “conditional formula” to show a column on the default New Experience forms when the current user a specific person (people column-single input).eg=if([$CurrentUser.email] == ‘name @ domain dot com’, ‘true’, ‘false’)What are the right properties and where can I find the list for this or any column for that matter, so can learn to solve these questions on my own. ANDSimilarly the correct syntax/properties to use for say a people column, MS help shows this, =if([$Owner.email] == ‘name @ domain dot com’, ‘true’, ‘false’) I assume “Owner.email” is the created by person’s email but that is not working when I change it to local user/email. Thanks for any direction, suggestions. Read More
Data Retention, Compliance, and Litigation Holds
We recently revamped our data retention policies and now I need to set up everything in M365. In the past, we would enable litigation hold under the user’s account. Since that only does email, that is not enough.
We are now drastically shortening our retention policy and it’s critical that all data for a user is accessible if they were brought into a litigation issue. So if we were subpoenaed, I would “freeze” the users data and then it would be possible to search if we were required 1/2/3 months down the road. Is the best way to do this by starting an eDiscovery search and placing everything on hold but not searching for anything? Then, if we were required to search the account, I would edit that eDiscovery hold to include specific queries? Or maybe I would create a “Litigation Hold” retention policy outside of the new default one that would hold their data indefinitely? That seems like a pain to exclude the user and then add them to the other and probably not efficient.
Looking for advice from anyone who does this a lot as Microsoft gives a ton of options.. which is great, but it makes it difficult to know the best way when handling critical data.
We recently revamped our data retention policies and now I need to set up everything in M365. In the past, we would enable litigation hold under the user’s account. Since that only does email, that is not enough. We are now drastically shortening our retention policy and it’s critical that all data for a user is accessible if they were brought into a litigation issue. So if we were subpoenaed, I would “freeze” the users data and then it would be possible to search if we were required 1/2/3 months down the road. Is the best way to do this by starting an eDiscovery search and placing everything on hold but not searching for anything? Then, if we were required to search the account, I would edit that eDiscovery hold to include specific queries? Or maybe I would create a “Litigation Hold” retention policy outside of the new default one that would hold their data indefinitely? That seems like a pain to exclude the user and then add them to the other and probably not efficient. Looking for advice from anyone who does this a lot as Microsoft gives a ton of options.. which is great, but it makes it difficult to know the best way when handling critical data. Read More
lsqcurvefit not working properly
Hi all, I have multiple sets of data that are to be fitted by my fitting function. Since these data sets are kind of related, what I did was to use an inital guess to find the parameter values for the first dataset, and then use the parameter values as the guess for the second dataset so on and forth. However, the fitting was really bad. May I ask if there is another way around this kind of problem involving fitting of multiple datasets?
tic
%% Preparation
clear; clc
data = importdata("Experimental dataTransient AbsorptionFCPIB-293K-2.5mW-400nm-Jan072021 -ibg -bg -chirp.csv"); % insert file path within parenthesis
%% Preamble
% Fundamental constants
h = 4.0135667696*10^-15; % units: eV/ Hz
c = 3*10^8; % SI units
kB = 8.617333268*10^-5; % units: eV/ K
% Data
wavelength = data(1:end, 1); % contains all of the wavelengths
delay_t = data(1, 1:end); % conatains all of the delay times
E = (h*c)./(wavelength*10^-9); % contains all of the probe energies
% Range of data needed
Range_E = E>=1.5 & E<=2.2;
Range_W = wavelength >= (h*c)/(2.2*10^-9) & wavelength <= (h*c)/(1.5*10^-9);
Range_T = delay_t>=0.5 & delay_t<=1000;
E_p = E(Range_E); % probe energies for scatterplot
w_p = wavelength(Range_W);
delay_T = delay_t(Range_T);
Range_Efit = E_p>=1.62 & E_p<=max(E_p);
Range_Wfit = w_p >= (h*c)/(2.2*10^-9) & w_p <= (h*c)/(1.62*10^-9);
E_fit = E_p(Range_Efit); % probe energies for fitting
W_fit = w_p(Range_Wfit);
t_min = min(delay_T);
t_max = max(delay_T);
w_min = min(w_p);
w_max = max(w_p);
[row1, col1] = find(data == w_min);
[row2, col2] = find(data == w_max);
[row3, col3] = find(data == t_min);
[row4, col4] = find(data == t_max);
% New cleaned up data
data_new = data(row1:row2, col3:col4);% new data containing required delta A
% for n = 1:length(delay_T)
% delta_Abs(:,n) = -1*data_new(:,n);
% delta_Abs_norm(:,n) = delta_Abs(:,n)/max(delta_Abs(:,n));
% delta_Abs_fit(:,n) = data_new(Range_Wfit,n);
% delta_Abs_norm_fit(:,n) = delta_Abs_fit(:,n)/max(delta_Abs_fit(:, n));
% % plot command
% plot(E_p, delta_Abs_norm)
% xlabel(‘Probe Energy (eV)’)
% ylabel(‘Normalised Delta A (a.u.)’)
% legend(‘Experimental Data’)
% end
% Fitting function: Maxwell-Boltzmann distribution
function F = MB(y, e_fit)
data = importdata("Experimental dataTransient AbsorptionFCPIB-293K-2.5mW-400nm-Jan072021 -ibg -bg -chirp.csv");
h = 4.0135667696*10^-15;
c = 3*10^8;
kB = 8.617333268*10^-5;
delay_t = data(1, :);
Range_T = delay_t>=0.5 & delay_t<=1000;
delay_T = delay_t(Range_T);
wavelength = data(1:end, 1);
E = (h*c)./(wavelength*10^-9);
Range_E = E>=1.5 & E<=2.2;
E_p = E(Range_E);
Range_Efit = E_p>=1.62 & E_p<=max(E_p);
E_fit = E_p(Range_Efit);
for i = 1:length(E_fit)
E_fit = e_fit(i);
F(i) = y(1).*exp(-(E_fit./(kB.*y(2)))) + y(3);
end
F = F(:);
end
% For loop to create required datasets for plotting
for n = 2:length(delay_T)
delta_Abs(:,1) = -1*data_new(:,1);
delta_Abs_norm(:,1) = delta_Abs(:,1)./max(abs(delta_Abs(:,1)));
delta_Abs_fit(:,1) = data_new(Range_Wfit,1);
delta_Abs_norm_fit(:,1) = delta_Abs_norm(Range_Wfit);
delta_Abs(:,n) = -1*data_new(:,n);
delta_Abs_norm(:,n) = delta_Abs(:,n)./max(abs(delta_Abs(:,n)));
delta_Abs_fit(:,n) = data_new(Range_Wfit,n);
delta_Abs_norm_fit(:,n) = delta_Abs_norm(Range_Wfit);
% lsqcurvefit
optim_lsq = optimoptions(‘lsqcurvefit’, ‘Algorithm’, ‘levenberg-marquardt’, ‘MaxFunctionEvaluations’,10^20, ‘MaxIterations’, 10^20, ‘FunctionTolerance’,10^-20, ‘StepTolerance’, 10^-20);
lb = [0, 293, -1]; ub = [Inf, 6000, 1];
lb1 = [0, 293, -1]; ub1 = [Inf, 2000, 1];
lb2 = [0, 293, -1]; ub2 = [Inf, 1200, 1];
lb3 = [0, 293, -1]; ub3 = [Inf, 1000, 1];
lb4 = [0, 293, -1]; ub4 = [Inf, 750, 1];
y1 = [2*10^7, 1000, 0.5];
y2 = [2*10^7, 800, 0.5];
y3 = [2*10^10, 800, 0.5];
y4 = [2*10^11, 600, 0.5];
y5 = [2*10^14, 600, 0.5];
y(1,:) = lsqcurvefit(@MB, y1, E_fit, delta_Abs_norm_fit(:, 1), lb1, ub1, optim_lsq);
y(n,:) = lsqcurvefit(@MB, y(n-1, :), E_fit, delta_Abs_norm_fit(:, n), lb, ub, optim_lsq);
% plot command
plot(E_p, delta_Abs_norm)
hold on
plot(E_fit, MB(y(1,:), E_fit), ‘red’)
plot(E_fit, MB(y(n,:), E_fit), ‘red’)
xlabel(‘Probe Energy (eV)’)
ylabel(‘Normalised Delta A (a.u.)’)
legend(‘Fitted curve’)
end
carrier_T = y(:,2);
disp(carrier_T)
toc
%% Miscellaneous
% For a rectangular pic:
% drag horizontally until it just covers the letter ‘c’ in the word ‘col’
% For a square pic:
% drag horizontall until it just covers the letter ‘o’ in the word ‘Contribution’ in the next line)
% legend(‘Experimental Data’, ‘Fitted Curve’, ‘Carrier Contribution’,’Excitonic Contribution’)Hi all, I have multiple sets of data that are to be fitted by my fitting function. Since these data sets are kind of related, what I did was to use an inital guess to find the parameter values for the first dataset, and then use the parameter values as the guess for the second dataset so on and forth. However, the fitting was really bad. May I ask if there is another way around this kind of problem involving fitting of multiple datasets?
tic
%% Preparation
clear; clc
data = importdata("Experimental dataTransient AbsorptionFCPIB-293K-2.5mW-400nm-Jan072021 -ibg -bg -chirp.csv"); % insert file path within parenthesis
%% Preamble
% Fundamental constants
h = 4.0135667696*10^-15; % units: eV/ Hz
c = 3*10^8; % SI units
kB = 8.617333268*10^-5; % units: eV/ K
% Data
wavelength = data(1:end, 1); % contains all of the wavelengths
delay_t = data(1, 1:end); % conatains all of the delay times
E = (h*c)./(wavelength*10^-9); % contains all of the probe energies
% Range of data needed
Range_E = E>=1.5 & E<=2.2;
Range_W = wavelength >= (h*c)/(2.2*10^-9) & wavelength <= (h*c)/(1.5*10^-9);
Range_T = delay_t>=0.5 & delay_t<=1000;
E_p = E(Range_E); % probe energies for scatterplot
w_p = wavelength(Range_W);
delay_T = delay_t(Range_T);
Range_Efit = E_p>=1.62 & E_p<=max(E_p);
Range_Wfit = w_p >= (h*c)/(2.2*10^-9) & w_p <= (h*c)/(1.62*10^-9);
E_fit = E_p(Range_Efit); % probe energies for fitting
W_fit = w_p(Range_Wfit);
t_min = min(delay_T);
t_max = max(delay_T);
w_min = min(w_p);
w_max = max(w_p);
[row1, col1] = find(data == w_min);
[row2, col2] = find(data == w_max);
[row3, col3] = find(data == t_min);
[row4, col4] = find(data == t_max);
% New cleaned up data
data_new = data(row1:row2, col3:col4);% new data containing required delta A
% for n = 1:length(delay_T)
% delta_Abs(:,n) = -1*data_new(:,n);
% delta_Abs_norm(:,n) = delta_Abs(:,n)/max(delta_Abs(:,n));
% delta_Abs_fit(:,n) = data_new(Range_Wfit,n);
% delta_Abs_norm_fit(:,n) = delta_Abs_fit(:,n)/max(delta_Abs_fit(:, n));
% % plot command
% plot(E_p, delta_Abs_norm)
% xlabel(‘Probe Energy (eV)’)
% ylabel(‘Normalised Delta A (a.u.)’)
% legend(‘Experimental Data’)
% end
% Fitting function: Maxwell-Boltzmann distribution
function F = MB(y, e_fit)
data = importdata("Experimental dataTransient AbsorptionFCPIB-293K-2.5mW-400nm-Jan072021 -ibg -bg -chirp.csv");
h = 4.0135667696*10^-15;
c = 3*10^8;
kB = 8.617333268*10^-5;
delay_t = data(1, :);
Range_T = delay_t>=0.5 & delay_t<=1000;
delay_T = delay_t(Range_T);
wavelength = data(1:end, 1);
E = (h*c)./(wavelength*10^-9);
Range_E = E>=1.5 & E<=2.2;
E_p = E(Range_E);
Range_Efit = E_p>=1.62 & E_p<=max(E_p);
E_fit = E_p(Range_Efit);
for i = 1:length(E_fit)
E_fit = e_fit(i);
F(i) = y(1).*exp(-(E_fit./(kB.*y(2)))) + y(3);
end
F = F(:);
end
% For loop to create required datasets for plotting
for n = 2:length(delay_T)
delta_Abs(:,1) = -1*data_new(:,1);
delta_Abs_norm(:,1) = delta_Abs(:,1)./max(abs(delta_Abs(:,1)));
delta_Abs_fit(:,1) = data_new(Range_Wfit,1);
delta_Abs_norm_fit(:,1) = delta_Abs_norm(Range_Wfit);
delta_Abs(:,n) = -1*data_new(:,n);
delta_Abs_norm(:,n) = delta_Abs(:,n)./max(abs(delta_Abs(:,n)));
delta_Abs_fit(:,n) = data_new(Range_Wfit,n);
delta_Abs_norm_fit(:,n) = delta_Abs_norm(Range_Wfit);
% lsqcurvefit
optim_lsq = optimoptions(‘lsqcurvefit’, ‘Algorithm’, ‘levenberg-marquardt’, ‘MaxFunctionEvaluations’,10^20, ‘MaxIterations’, 10^20, ‘FunctionTolerance’,10^-20, ‘StepTolerance’, 10^-20);
lb = [0, 293, -1]; ub = [Inf, 6000, 1];
lb1 = [0, 293, -1]; ub1 = [Inf, 2000, 1];
lb2 = [0, 293, -1]; ub2 = [Inf, 1200, 1];
lb3 = [0, 293, -1]; ub3 = [Inf, 1000, 1];
lb4 = [0, 293, -1]; ub4 = [Inf, 750, 1];
y1 = [2*10^7, 1000, 0.5];
y2 = [2*10^7, 800, 0.5];
y3 = [2*10^10, 800, 0.5];
y4 = [2*10^11, 600, 0.5];
y5 = [2*10^14, 600, 0.5];
y(1,:) = lsqcurvefit(@MB, y1, E_fit, delta_Abs_norm_fit(:, 1), lb1, ub1, optim_lsq);
y(n,:) = lsqcurvefit(@MB, y(n-1, :), E_fit, delta_Abs_norm_fit(:, n), lb, ub, optim_lsq);
% plot command
plot(E_p, delta_Abs_norm)
hold on
plot(E_fit, MB(y(1,:), E_fit), ‘red’)
plot(E_fit, MB(y(n,:), E_fit), ‘red’)
xlabel(‘Probe Energy (eV)’)
ylabel(‘Normalised Delta A (a.u.)’)
legend(‘Fitted curve’)
end
carrier_T = y(:,2);
disp(carrier_T)
toc
%% Miscellaneous
% For a rectangular pic:
% drag horizontally until it just covers the letter ‘c’ in the word ‘col’
% For a square pic:
% drag horizontall until it just covers the letter ‘o’ in the word ‘Contribution’ in the next line)
% legend(‘Experimental Data’, ‘Fitted Curve’, ‘Carrier Contribution’,’Excitonic Contribution’) Hi all, I have multiple sets of data that are to be fitted by my fitting function. Since these data sets are kind of related, what I did was to use an inital guess to find the parameter values for the first dataset, and then use the parameter values as the guess for the second dataset so on and forth. However, the fitting was really bad. May I ask if there is another way around this kind of problem involving fitting of multiple datasets?
tic
%% Preparation
clear; clc
data = importdata("Experimental dataTransient AbsorptionFCPIB-293K-2.5mW-400nm-Jan072021 -ibg -bg -chirp.csv"); % insert file path within parenthesis
%% Preamble
% Fundamental constants
h = 4.0135667696*10^-15; % units: eV/ Hz
c = 3*10^8; % SI units
kB = 8.617333268*10^-5; % units: eV/ K
% Data
wavelength = data(1:end, 1); % contains all of the wavelengths
delay_t = data(1, 1:end); % conatains all of the delay times
E = (h*c)./(wavelength*10^-9); % contains all of the probe energies
% Range of data needed
Range_E = E>=1.5 & E<=2.2;
Range_W = wavelength >= (h*c)/(2.2*10^-9) & wavelength <= (h*c)/(1.5*10^-9);
Range_T = delay_t>=0.5 & delay_t<=1000;
E_p = E(Range_E); % probe energies for scatterplot
w_p = wavelength(Range_W);
delay_T = delay_t(Range_T);
Range_Efit = E_p>=1.62 & E_p<=max(E_p);
Range_Wfit = w_p >= (h*c)/(2.2*10^-9) & w_p <= (h*c)/(1.62*10^-9);
E_fit = E_p(Range_Efit); % probe energies for fitting
W_fit = w_p(Range_Wfit);
t_min = min(delay_T);
t_max = max(delay_T);
w_min = min(w_p);
w_max = max(w_p);
[row1, col1] = find(data == w_min);
[row2, col2] = find(data == w_max);
[row3, col3] = find(data == t_min);
[row4, col4] = find(data == t_max);
% New cleaned up data
data_new = data(row1:row2, col3:col4);% new data containing required delta A
% for n = 1:length(delay_T)
% delta_Abs(:,n) = -1*data_new(:,n);
% delta_Abs_norm(:,n) = delta_Abs(:,n)/max(delta_Abs(:,n));
% delta_Abs_fit(:,n) = data_new(Range_Wfit,n);
% delta_Abs_norm_fit(:,n) = delta_Abs_fit(:,n)/max(delta_Abs_fit(:, n));
% % plot command
% plot(E_p, delta_Abs_norm)
% xlabel(‘Probe Energy (eV)’)
% ylabel(‘Normalised Delta A (a.u.)’)
% legend(‘Experimental Data’)
% end
% Fitting function: Maxwell-Boltzmann distribution
function F = MB(y, e_fit)
data = importdata("Experimental dataTransient AbsorptionFCPIB-293K-2.5mW-400nm-Jan072021 -ibg -bg -chirp.csv");
h = 4.0135667696*10^-15;
c = 3*10^8;
kB = 8.617333268*10^-5;
delay_t = data(1, :);
Range_T = delay_t>=0.5 & delay_t<=1000;
delay_T = delay_t(Range_T);
wavelength = data(1:end, 1);
E = (h*c)./(wavelength*10^-9);
Range_E = E>=1.5 & E<=2.2;
E_p = E(Range_E);
Range_Efit = E_p>=1.62 & E_p<=max(E_p);
E_fit = E_p(Range_Efit);
for i = 1:length(E_fit)
E_fit = e_fit(i);
F(i) = y(1).*exp(-(E_fit./(kB.*y(2)))) + y(3);
end
F = F(:);
end
% For loop to create required datasets for plotting
for n = 2:length(delay_T)
delta_Abs(:,1) = -1*data_new(:,1);
delta_Abs_norm(:,1) = delta_Abs(:,1)./max(abs(delta_Abs(:,1)));
delta_Abs_fit(:,1) = data_new(Range_Wfit,1);
delta_Abs_norm_fit(:,1) = delta_Abs_norm(Range_Wfit);
delta_Abs(:,n) = -1*data_new(:,n);
delta_Abs_norm(:,n) = delta_Abs(:,n)./max(abs(delta_Abs(:,n)));
delta_Abs_fit(:,n) = data_new(Range_Wfit,n);
delta_Abs_norm_fit(:,n) = delta_Abs_norm(Range_Wfit);
% lsqcurvefit
optim_lsq = optimoptions(‘lsqcurvefit’, ‘Algorithm’, ‘levenberg-marquardt’, ‘MaxFunctionEvaluations’,10^20, ‘MaxIterations’, 10^20, ‘FunctionTolerance’,10^-20, ‘StepTolerance’, 10^-20);
lb = [0, 293, -1]; ub = [Inf, 6000, 1];
lb1 = [0, 293, -1]; ub1 = [Inf, 2000, 1];
lb2 = [0, 293, -1]; ub2 = [Inf, 1200, 1];
lb3 = [0, 293, -1]; ub3 = [Inf, 1000, 1];
lb4 = [0, 293, -1]; ub4 = [Inf, 750, 1];
y1 = [2*10^7, 1000, 0.5];
y2 = [2*10^7, 800, 0.5];
y3 = [2*10^10, 800, 0.5];
y4 = [2*10^11, 600, 0.5];
y5 = [2*10^14, 600, 0.5];
y(1,:) = lsqcurvefit(@MB, y1, E_fit, delta_Abs_norm_fit(:, 1), lb1, ub1, optim_lsq);
y(n,:) = lsqcurvefit(@MB, y(n-1, :), E_fit, delta_Abs_norm_fit(:, n), lb, ub, optim_lsq);
% plot command
plot(E_p, delta_Abs_norm)
hold on
plot(E_fit, MB(y(1,:), E_fit), ‘red’)
plot(E_fit, MB(y(n,:), E_fit), ‘red’)
xlabel(‘Probe Energy (eV)’)
ylabel(‘Normalised Delta A (a.u.)’)
legend(‘Fitted curve’)
end
carrier_T = y(:,2);
disp(carrier_T)
toc
%% Miscellaneous
% For a rectangular pic:
% drag horizontally until it just covers the letter ‘c’ in the word ‘col’
% For a square pic:
% drag horizontall until it just covers the letter ‘o’ in the word ‘Contribution’ in the next line)
% legend(‘Experimental Data’, ‘Fitted Curve’, ‘Carrier Contribution’,’Excitonic Contribution’) lsqcurvefit MATLAB Answers — New Questions
Sorting on multiples in same column
Hi there – Cannot figure this out. I have a list of items in a column as follows:
5″ White
5″ Red
5″ Blue
11″ White
11″ Red
11″ Blue
17″ White
17″ Red
17″ Blue
There are several more sizes but I need to sort this sheet so that the colors fall in order and the sizes order as 11, 17, 5.
11″ White
17″ White
5″ White
11″ Red
17″ Red
5″ Red
And so on. The colors are in a specific order not based on alphabet.
Thank you in advance!
Hi there – Cannot figure this out. I have a list of items in a column as follows:5″ White5″ Red5″ Blue11″ White11″ Red11″ Blue17″ White17″ Red17″ BlueThere are several more sizes but I need to sort this sheet so that the colors fall in order and the sizes order as 11, 17, 5. 11″ White17″ White5″ White11″ Red17″ Red5″ RedAnd so on. The colors are in a specific order not based on alphabet.Thank you in advance! Read More
f = x^2024. Write a loop to find how many times f needs to be differentiated to get a result of zero.
A sequence of functions F0, F1, F2…is defined as follows, for x a positive real number:#
F0 = x^2024
For n>=1, the function Fn is the derivative of F(n-1), with respect to x.
Find the first value of n for which Fn = 0A sequence of functions F0, F1, F2…is defined as follows, for x a positive real number:#
F0 = x^2024
For n>=1, the function Fn is the derivative of F(n-1), with respect to x.
Find the first value of n for which Fn = 0 A sequence of functions F0, F1, F2…is defined as follows, for x a positive real number:#
F0 = x^2024
For n>=1, the function Fn is the derivative of F(n-1), with respect to x.
Find the first value of n for which Fn = 0 loops, differentiation MATLAB Answers — New Questions
Rename the indices of a vector in a certain way.
Hi all,
My code below has a vector and its index vector . It goes throguh the elements of and when it finds a zero element, it removes its index from the orginal index vector.
My problem here is: suppose the updated index vector is . How can I rename this vector so it increases in an acending order? For example: the first element in the updated index vector is , I want this to be , the second element in the updated index vector is , I want this to become , and so on so forth.
%define the index vector
idx = [1 2 3 4 5];
%define the vector
A = [5 0 6 0 3];
%initialise the vector that has all indices of zero elements
zero_indices = [];
%go through the elements of vector A
for uu = 1:numel(A)
%if the element is zero
if A(uu)==0
%assign its index to the zero-elements index vector
zeroindex = uu;
%collect all results from iterations
zero_indices = [zero_indices ; zeroindex];
end
end
%update the original index vector by removing the indicies that correspond
%to zero elements
idx(zero_indices) = [];
%rename the indices os that they beocome 1, 2, 3, …
Any help would be appreicted.
Thanks.Hi all,
My code below has a vector and its index vector . It goes throguh the elements of and when it finds a zero element, it removes its index from the orginal index vector.
My problem here is: suppose the updated index vector is . How can I rename this vector so it increases in an acending order? For example: the first element in the updated index vector is , I want this to be , the second element in the updated index vector is , I want this to become , and so on so forth.
%define the index vector
idx = [1 2 3 4 5];
%define the vector
A = [5 0 6 0 3];
%initialise the vector that has all indices of zero elements
zero_indices = [];
%go through the elements of vector A
for uu = 1:numel(A)
%if the element is zero
if A(uu)==0
%assign its index to the zero-elements index vector
zeroindex = uu;
%collect all results from iterations
zero_indices = [zero_indices ; zeroindex];
end
end
%update the original index vector by removing the indicies that correspond
%to zero elements
idx(zero_indices) = [];
%rename the indices os that they beocome 1, 2, 3, …
Any help would be appreicted.
Thanks. Hi all,
My code below has a vector and its index vector . It goes throguh the elements of and when it finds a zero element, it removes its index from the orginal index vector.
My problem here is: suppose the updated index vector is . How can I rename this vector so it increases in an acending order? For example: the first element in the updated index vector is , I want this to be , the second element in the updated index vector is , I want this to become , and so on so forth.
%define the index vector
idx = [1 2 3 4 5];
%define the vector
A = [5 0 6 0 3];
%initialise the vector that has all indices of zero elements
zero_indices = [];
%go through the elements of vector A
for uu = 1:numel(A)
%if the element is zero
if A(uu)==0
%assign its index to the zero-elements index vector
zeroindex = uu;
%collect all results from iterations
zero_indices = [zero_indices ; zeroindex];
end
end
%update the original index vector by removing the indicies that correspond
%to zero elements
idx(zero_indices) = [];
%rename the indices os that they beocome 1, 2, 3, …
Any help would be appreicted.
Thanks. index, matlab coder, vector, while loop, remove, delete MATLAB Answers — New Questions
How can I change the axis intervals using powers?
Hi.
I recently was trying to make a scientific graph, which required the X Axis to be in even intervals of powers of 10 (i.e. 0.1, 10, 100, 1000, etc.) with no in-betweeners. When I tried to use the xtick function, the command worked, but it didn’t create the necessary even spacing required at the intervals. What can I do? (The code and images are below.)
size = particle_size.("Size (d.nm)");
number = particle_size.("Number (Percent)");
plot(normalize(size,’range’,[0.1 10000]),number,"red",LineWidth=0.5)
xlim([0.1 10000])
ylim([0 14])
title("Particle Size Of Carbon Leaves",FontSize=20,FontWeight="bold")
xlabel("Size (d.nm)",FontSize=14,FontWeight="bold")
ylabel("Number (Percent)",FontSize=14,FontWeight="bold")
legend("Carbon Leaves",FontWeight="bold")
xtick = [0.1, 1, 10, 100, 1000, 10000];
box on
ax = gca;
ax.LineWidth = 2;
ax.FontSize = 12;
ax.XTick = xtick;
(The graph required)
(What MATLAB gave me)Hi.
I recently was trying to make a scientific graph, which required the X Axis to be in even intervals of powers of 10 (i.e. 0.1, 10, 100, 1000, etc.) with no in-betweeners. When I tried to use the xtick function, the command worked, but it didn’t create the necessary even spacing required at the intervals. What can I do? (The code and images are below.)
size = particle_size.("Size (d.nm)");
number = particle_size.("Number (Percent)");
plot(normalize(size,’range’,[0.1 10000]),number,"red",LineWidth=0.5)
xlim([0.1 10000])
ylim([0 14])
title("Particle Size Of Carbon Leaves",FontSize=20,FontWeight="bold")
xlabel("Size (d.nm)",FontSize=14,FontWeight="bold")
ylabel("Number (Percent)",FontSize=14,FontWeight="bold")
legend("Carbon Leaves",FontWeight="bold")
xtick = [0.1, 1, 10, 100, 1000, 10000];
box on
ax = gca;
ax.LineWidth = 2;
ax.FontSize = 12;
ax.XTick = xtick;
(The graph required)
(What MATLAB gave me) Hi.
I recently was trying to make a scientific graph, which required the X Axis to be in even intervals of powers of 10 (i.e. 0.1, 10, 100, 1000, etc.) with no in-betweeners. When I tried to use the xtick function, the command worked, but it didn’t create the necessary even spacing required at the intervals. What can I do? (The code and images are below.)
size = particle_size.("Size (d.nm)");
number = particle_size.("Number (Percent)");
plot(normalize(size,’range’,[0.1 10000]),number,"red",LineWidth=0.5)
xlim([0.1 10000])
ylim([0 14])
title("Particle Size Of Carbon Leaves",FontSize=20,FontWeight="bold")
xlabel("Size (d.nm)",FontSize=14,FontWeight="bold")
ylabel("Number (Percent)",FontSize=14,FontWeight="bold")
legend("Carbon Leaves",FontWeight="bold")
xtick = [0.1, 1, 10, 100, 1000, 10000];
box on
ax = gca;
ax.LineWidth = 2;
ax.FontSize = 12;
ax.XTick = xtick;
(The graph required)
(What MATLAB gave me) graphs, axis MATLAB Answers — New Questions
What do you think about RSVP in Outlook?
Hello Calendar Community,
RSVP (responding to meeting invitations) is an area with lots of opportunity for improvements in Outlook Calendar. I’m reaching out to gather your feedback on RSVP.
We’re particularly interested in understanding:
Ease of Use: How intuitive and user-friendly do you find the current RSVP process?
Functionality: Are there any features you wish were included to improve the RSVP experience?
Efficiency: How could we make RSVPing quicker and more efficient for you?
Overall Experience: Any other comments on your overall experience with the RSVP functionality?
Feel free to share your thoughts in the comments. I am really eager for some insights from our community and its power calendar users.
cheers,
Gio
Hello Calendar Community,
RSVP (responding to meeting invitations) is an area with lots of opportunity for improvements in Outlook Calendar. I’m reaching out to gather your feedback on RSVP.
We’re particularly interested in understanding:
Ease of Use: How intuitive and user-friendly do you find the current RSVP process?
Functionality: Are there any features you wish were included to improve the RSVP experience?
Efficiency: How could we make RSVPing quicker and more efficient for you?
Overall Experience: Any other comments on your overall experience with the RSVP functionality?
Feel free to share your thoughts in the comments. I am really eager for some insights from our community and its power calendar users.
cheers,
Gio Read More
Visual Studio AI Toolkit : Building Phi-3 GenAI Applications
Level up your Generative AI development with Microsoft’s AI Toolkit! In the previous blog, we explored how AI Toolkit empowers you to run LLMs/SLMs locally.
AI toolkit lets us to,
Run pre-optimized AI models locally: Get started quickly with models designed for various setups, including Windows 11 running with DirectML acceleration or direct CPU, Linux with NVIDIA GPUs, or CPU-only environments.
Test and integrate models seamlessly: Experiment with models in a user-friendly playground or use a REST API to incorporate them directly into your application.
Fine-tune models for specific needs: Customize pre-trained models (like popular SLMs Phi-3 and Mistral) locally or in the cloud to enhance performance, tailor responses, and control their style.
Deploy your AI-powered features: Choose between cloud deployment or embedding them within your device applications.
Port Forwarding, a valuable feature within the AI Toolkit, serves as a crucial gateway for seamless communication with the GenAI model. Whether it’s through a straightforward API call or leveraging the SDKs, this functionality greatly enhances our ability to harness the power of the LLM/SLM. By enabling Port Forwarding, a plethora of new scenarios unfold, unlocking the full potential of our interactions with the model.
Port forwarding is like setting up a special path for data to travel between two devices over the internet. In the context of AI Toolkit, port forwarding involves configuring a pathway for communication between the LLM and external applications or systems, enabling seamless data exchange and interaction.
AI toolkit auto forwards the port to 5272 by default. If needed this can be modified or new ports can be added. This can be seen the moment we load the AI Toolkit extension on VS Code. A notification can be seen on the right side of the screen stating the “Your application running on port 5272 is available”
The 5272 is default port assigned by AI Toolkit, if we wish to add more ports, that can be done by navigating to the PORTS terminal on VS Code and then clicking on the “Add Ports” button.
In this, we can see the section “Forwarded address”. This is the address which will be used for communicating with the SLM. For this tutorial, Phi-3 will be used. This is a Small Language Model from Microsoft. It can be downloaded from the Model Catalog section.
Testing and comprehending the API Endpoint on POSTMAN:
Testing out an application from the API testing application, gives a clear knowledge about the API specification. This can also be done using the coding language, but for this demonstration, I will be showcasing it through the POSTMAN application. Postman application needs to be downloaded and installed on the local machine. Also sign up and create an account if you don’t have one. Once the application is launched, click on create a new request, it will be displayed as “+’” icon.
In order to do this testing, we would need some basic information about the API that we are testing. Details like Request method, Request URL, request body, type of the request body, authentication type are some of the mandatory things which will be needed. For the Visual Studio Code AI Toolkit API with Phi-3-mini-128k-cuda-int4-onnx model, the details are as follows,
Authentication: None
Request method: POST
Request URL:
http://127.0.0.1:5272/v1/chat/completions
Request Body type: Raw/JSON
Request Body:
{
“model”: “Phi-3-mini-128k-cuda-int4-onnx”,
“messages”: [
{
“role”: “user”,
“content”: “Hi”
}
],
“temperature”: 0.7,
“top_p”: 1,
“top_k”: 10,
“max_tokens”: 100,
“stream”: false
}
Authentication will be defaulting to None. So, it can be retained here to None as it is. HTTP request method here would be POST. The Request URL must be checked according to the Port that has been assigned, if it is the default port which is assigned by the visual studio ai toolkit, it will be 5272. Incase, it is changed to any other port, it must be changed in the URL as well. This will be a HTTP request and the URL must contain the URL address, followed by the port and the routes must be set as shown above.
The “model” parameter in the request body must have the same model that is being loaded in the VS Code AI Toolkit – playground section.
Request body type must be set to Raw and from the dropdown, select JSON.
The streaming parameter must be set to false, else the response will be streamed and divided into sub-classes of JSON which is hard to comprehend. In-case if the application needs streaming, then the parameter can be set to TRUE.
Once these are ready, use the Send button and wait for the response. If the API call is successful, 200 OK will be displayed and a response body will be visible in the Body tab.
NOTE: The VS Code AI Toolkit must be running in the background, and load the model in the playground before sending the API response in Postman.
The response of the above request is as follows,
Meanwhile, this will also be reflected on the VS Code AI toolkit Output window as well.
The response body carries quite a lot of information, the answer that will be used in the application is in the “content” division. The code must navigate to the first section of the choices then the messages and finally to the content section. In python, it can be done by,
chat_completion.choices[0].messages.content
This will be further used while building the playground application in the later part of this tutorial.
The response body also provides some more useful information like the ID, created stamp, finish reason to name a few. The role parameter shows that the response is from the model and hence shows “assistant”.
Code snippet can also be generated with the POSTMAN app, which can be then used for testing the API. Following is the example for the Python Code using the HTTP Client.
Using the VS Code AI Toolkit with Python:
from openai import OpenAI
client = OpenAI(
base_url=”http://127.0.0.1:5272/v1/”,
api_key=”xyz” # required by API but not used
)
chat_completion = client.chat.completions.create(
messages=[
{
“role”: “user”,”content”: “What is the capital of India?””,
}
],
model=”Phi-3-mini-128k-cuda-int4-onnx”,
)
print(chat_completion.choices[0].message.content)
The Python script interacts with an API (local instance of OpenAI’s API) to get a chat completion.
Step-by-step explanation of Python Implementation:
Importing the OpenAI library: The script starts by importing the OpenAI class from the openai package. This class is used to interact with OpenAI’s API. It can be installed using the simple python command as follows.
pip install openai
Although we are not communicating to the OpenAI’s API, we are utilizing the OS library to interact with the model running in local machine.
Create an OpenAI client instance: Initialize an OpenAI client with a base URL pointing to http://127.0.0.1:5272/v1/, which suggests the API is hosted locally rather than on OpenAI’s cloud servers. An API key, “XYZ”, is also provided, which is noted as required by the API but not used in this context. The API key can be set to anything and not necessarily XYZ.
Create a chat completion request: The script then creates a chat completion request using the chat.completions.create method of the client. This method is called with two parameters:
messages: A list containing a single message dictionary where the role is set to “user” and the content is the question ” What is the capital of India?”. This structure mimics a chat interaction where a user asks a question.
model: Specifies the model to use for generating the completion, in this case, “Phi-3-mini-128k-cuda-int4-onnx”. This indicates a specific model configuration.
Print the response: Finally, the script prints the content of the first message from the response’s choices. API returns a list of possible completions (choices), and it accesses the content of the message from the first choice to display the answer to the user’s question as demonstrated in the POSTMAN section.
Run the code in a new VS Code window. Preferably use a virtual environment to execute this code. Python is a prerequisite. To learn more, click here.
Execute the code using, the command
python <filename>.py #replace filename with the respective filename.
or click on the run button on the top right side of the Visual Studio Code window.
The response is now printed on the terminal.
Developing Basic Application:
Similarly, we can use it in applications as well. To demonstrate, lets build a basic application using Streamlit and python. Streamlit turns python scripts into shareable web apps in minutes. To know more click here. To install streamlit, use the following command in the python terminal/VS Code terminal.
pip install streamlit
The following script creates a web-based chat interface using streamlit where users can input queries, which are then sent to an AI model via a local OpenAI API server. The AI’s responses are displayed back in the chat interface, facilitating a conversational interaction.
import streamlit as st
from openai import OpenAI
client = OpenAI(
base_url=”http://127.0.0.1:5272/v1/”,
api_key=”xyz” # required by API but not used
)
st.title(“Chat with Phi-3”)
query = st.chat_input(“Enter query:”)
if query:
with st.chat_message(“user”):
st.write(query)
chat_completion = client.chat.completions.create(
messages=[
{“role”: “user”,”content”: “You are a helpful assistant and provides structured answers.”},
{“role”: “user”, “content”: query}
],
model=”Phi-3-mini-128k-cuda-int4-onnx”,
)
with st.chat_message(“assistant”):
st.write(chat_completion.choices[0].message.content)
Since the above code is using the streamlit, the startup command is also given in a different syntax, the command is as follows,
streamlit run <filename>.py #replace filename with the respective filename.
Upon successful execution, the streamlit pops up a new window in the Microsoft edge with the webpage.
This is how we can create GenAI applications by using the models running on local VS Code AI Toolkit environment. In the upcoming blog, lets see how to apply retrieval augmented generation using the AI Toolkit framework.
Microsoft Tech Community – Latest Blogs –Read More
Unrecognized function or variable ‘asbQuadcopterStart’.
I got the same problem as another case followed:
Unrecognized function or variable ‘asbQuadcopterStart’. – MATLAB Answers – MATLAB Central (mathworks.com)
Error Msg: Unrecognized function or variable ‘asbQuadcopterStart’.
But I am sure that both
Aerospace Blockset
Aerospace Toolbox
are installed in my computer. Which can be both showed on the attached image.
So, Which step I missed?
Thanks a lot!I got the same problem as another case followed:
Unrecognized function or variable ‘asbQuadcopterStart’. – MATLAB Answers – MATLAB Central (mathworks.com)
Error Msg: Unrecognized function or variable ‘asbQuadcopterStart’.
But I am sure that both
Aerospace Blockset
Aerospace Toolbox
are installed in my computer. Which can be both showed on the attached image.
So, Which step I missed?
Thanks a lot! I got the same problem as another case followed:
Unrecognized function or variable ‘asbQuadcopterStart’. – MATLAB Answers – MATLAB Central (mathworks.com)
Error Msg: Unrecognized function or variable ‘asbQuadcopterStart’.
But I am sure that both
Aerospace Blockset
Aerospace Toolbox
are installed in my computer. Which can be both showed on the attached image.
So, Which step I missed?
Thanks a lot! asbquadcopterstart, aerospace MATLAB Answers — New Questions