Month: September 2024
Fitting data to a Gaussian when data is a little bit skewed (but not too much)
Hello, I have some data below that should approx to a Gaussian.
1.00 NaN
2.00 4.00
3.00 3.00
4.00 6.00
5.00 9.00
6.00 7.00
7.00 9.00
8.00 57.00
9.00 141.00
10.00 205.00
11.00 204.00
12.00 190.00
13.00 86.00
14.00 23.00
15.00 5.00
16.00 4.00
17.00 7.00
18.00 5.00
19.00 7.00
20.00 4.00
21.00 5.00
I understand its not perfect, but when I give my gaussian fitting the parameters represented by the orange curve, it fails to do any kind of fit.
This is my Routine
b0 = 11.00
c0 = 1.73 % This is actually sqrt (fwhm guess = 3)
function [fwhm,xdataFine,fitGaus,xpeak,ypeak,rsquared]=myGaussianFit2(xdata,ydata, b0,c0)
%——————–Gaussian Fit—————————————-
%Input is xdata, ydata and must be in column vector format
%only two initial guesses required as the following are determine by ydata
a0 = max(ydata(:)); %-min(ydata(:));
d0 = min(ydata(:));
%b0 is the guess at x-location of peak
%c0 is guess at width of peak
%Output gives the fitted parameters as well as xpeak location and its
%yvalue (i.e. xpeak & ypeak
%————————————————————————-
%Define Gauss Equation (remember the . notation
gaussEqn =’a*exp(-0.5*((x-b)/(c^2)).^2)+d’;
%Use startpoint to define guess values (otherwise fit doesn’t perform well)
try
%f = fit(xdata,ydata,gaussEqn,’Normalize’,’off’, ‘StartPoint’,[a0,b0,sqrt(c0),d0]); %use c^2 instred of c to enforce postive sigma/fwhm
[f,gof]=fit(xdata,ydata,gaussEqn,’Normalize’,’off’, ‘StartPoint’,[a0,b0,sqrt(c0),d0]); %use c^2 instead of c to enforce postive sigma/fwhm
coeffs=coeffvalues(f);
a=coeffs(1); b=coeffs(2);
c=coeffs(3); %need to square it as used c^2 in fitting equation to enforce +ve values
c=c^2;
d=coeffs(4);
rsquared=gof.rsquare;
fwhm=c*sqrt(log(256));
% %Increase resolution of x data (by 30)
xdataFine=(linspace(xdata(1),xdata(end),100))’;
% Create high res Gauss function
fitGaus = a*exp(-0.5*((xdataFine-b)/c).^2)+d;
%Find max value and its x location
ypeak=max(fitGaus);
xpeak=b;
xpeak=mean(xpeak(:)); %Take mean incase more than one peak found
catch
a=0;b=0;c=0;d=0;xpeak=0;ypeak=0;
end
Is there anyhting I can do here to make the fit work, although I understand its not great, but I still think it should be able to fit something!Hello, I have some data below that should approx to a Gaussian.
1.00 NaN
2.00 4.00
3.00 3.00
4.00 6.00
5.00 9.00
6.00 7.00
7.00 9.00
8.00 57.00
9.00 141.00
10.00 205.00
11.00 204.00
12.00 190.00
13.00 86.00
14.00 23.00
15.00 5.00
16.00 4.00
17.00 7.00
18.00 5.00
19.00 7.00
20.00 4.00
21.00 5.00
I understand its not perfect, but when I give my gaussian fitting the parameters represented by the orange curve, it fails to do any kind of fit.
This is my Routine
b0 = 11.00
c0 = 1.73 % This is actually sqrt (fwhm guess = 3)
function [fwhm,xdataFine,fitGaus,xpeak,ypeak,rsquared]=myGaussianFit2(xdata,ydata, b0,c0)
%——————–Gaussian Fit—————————————-
%Input is xdata, ydata and must be in column vector format
%only two initial guesses required as the following are determine by ydata
a0 = max(ydata(:)); %-min(ydata(:));
d0 = min(ydata(:));
%b0 is the guess at x-location of peak
%c0 is guess at width of peak
%Output gives the fitted parameters as well as xpeak location and its
%yvalue (i.e. xpeak & ypeak
%————————————————————————-
%Define Gauss Equation (remember the . notation
gaussEqn =’a*exp(-0.5*((x-b)/(c^2)).^2)+d’;
%Use startpoint to define guess values (otherwise fit doesn’t perform well)
try
%f = fit(xdata,ydata,gaussEqn,’Normalize’,’off’, ‘StartPoint’,[a0,b0,sqrt(c0),d0]); %use c^2 instred of c to enforce postive sigma/fwhm
[f,gof]=fit(xdata,ydata,gaussEqn,’Normalize’,’off’, ‘StartPoint’,[a0,b0,sqrt(c0),d0]); %use c^2 instead of c to enforce postive sigma/fwhm
coeffs=coeffvalues(f);
a=coeffs(1); b=coeffs(2);
c=coeffs(3); %need to square it as used c^2 in fitting equation to enforce +ve values
c=c^2;
d=coeffs(4);
rsquared=gof.rsquare;
fwhm=c*sqrt(log(256));
% %Increase resolution of x data (by 30)
xdataFine=(linspace(xdata(1),xdata(end),100))’;
% Create high res Gauss function
fitGaus = a*exp(-0.5*((xdataFine-b)/c).^2)+d;
%Find max value and its x location
ypeak=max(fitGaus);
xpeak=b;
xpeak=mean(xpeak(:)); %Take mean incase more than one peak found
catch
a=0;b=0;c=0;d=0;xpeak=0;ypeak=0;
end
Is there anyhting I can do here to make the fit work, although I understand its not great, but I still think it should be able to fit something! Hello, I have some data below that should approx to a Gaussian.
1.00 NaN
2.00 4.00
3.00 3.00
4.00 6.00
5.00 9.00
6.00 7.00
7.00 9.00
8.00 57.00
9.00 141.00
10.00 205.00
11.00 204.00
12.00 190.00
13.00 86.00
14.00 23.00
15.00 5.00
16.00 4.00
17.00 7.00
18.00 5.00
19.00 7.00
20.00 4.00
21.00 5.00
I understand its not perfect, but when I give my gaussian fitting the parameters represented by the orange curve, it fails to do any kind of fit.
This is my Routine
b0 = 11.00
c0 = 1.73 % This is actually sqrt (fwhm guess = 3)
function [fwhm,xdataFine,fitGaus,xpeak,ypeak,rsquared]=myGaussianFit2(xdata,ydata, b0,c0)
%——————–Gaussian Fit—————————————-
%Input is xdata, ydata and must be in column vector format
%only two initial guesses required as the following are determine by ydata
a0 = max(ydata(:)); %-min(ydata(:));
d0 = min(ydata(:));
%b0 is the guess at x-location of peak
%c0 is guess at width of peak
%Output gives the fitted parameters as well as xpeak location and its
%yvalue (i.e. xpeak & ypeak
%————————————————————————-
%Define Gauss Equation (remember the . notation
gaussEqn =’a*exp(-0.5*((x-b)/(c^2)).^2)+d’;
%Use startpoint to define guess values (otherwise fit doesn’t perform well)
try
%f = fit(xdata,ydata,gaussEqn,’Normalize’,’off’, ‘StartPoint’,[a0,b0,sqrt(c0),d0]); %use c^2 instred of c to enforce postive sigma/fwhm
[f,gof]=fit(xdata,ydata,gaussEqn,’Normalize’,’off’, ‘StartPoint’,[a0,b0,sqrt(c0),d0]); %use c^2 instead of c to enforce postive sigma/fwhm
coeffs=coeffvalues(f);
a=coeffs(1); b=coeffs(2);
c=coeffs(3); %need to square it as used c^2 in fitting equation to enforce +ve values
c=c^2;
d=coeffs(4);
rsquared=gof.rsquare;
fwhm=c*sqrt(log(256));
% %Increase resolution of x data (by 30)
xdataFine=(linspace(xdata(1),xdata(end),100))’;
% Create high res Gauss function
fitGaus = a*exp(-0.5*((xdataFine-b)/c).^2)+d;
%Find max value and its x location
ypeak=max(fitGaus);
xpeak=b;
xpeak=mean(xpeak(:)); %Take mean incase more than one peak found
catch
a=0;b=0;c=0;d=0;xpeak=0;ypeak=0;
end
Is there anyhting I can do here to make the fit work, although I understand its not great, but I still think it should be able to fit something! fit, gaussian MATLAB Answers — New Questions
Building an app to send email using Microsoft Graph API
I am developing an application using C# that will be able to send email using Microsoft Graph API. My main intention is that using this application, different users from different companies (i.e. different email domains) will be able to send emails.
I am providing details of what I have done till now.
Suppose my company’s email domain is email address removed for privacy reasons.
The Azure admin of my company has registered an application through Azure App registration under multi-tenant option.
As this is a desktop application, we are using Redirect URI as default – https://login.microsoftonline.com/common/oauth2/nativeclientMy company’s azure admin (email address removed for privacy reasons) is the owner of the application.Delegated permission for Microsoft Graph API User.Read and Mail.Send is added.
In the code, I have used clientID from the Azure App registration page and tenantID as common
Then I use AcquireTokenInteractive() to acquire token interactively from user.
And then sending the mail –
So my question is, when someone from other domain tries to send email using this application, he/she is getting this window asking for approval for access token –
So, what happens when the user press request for approval? –
Does it trigger an email to xyz company azure admin for approval?Or xyz azure admin need to approve the request for the requested user from their azure ad admin page?Is Azure Admin access is absolutely necessary for this?Lastly, can you please let me know what is the best way to handle this scenario i.e. what settings or coding to be done so that different user from different companies (i.e. different domain like xyz.co.in) can send email using my application (registered in azure AD by my organization email address removed for privacy reasons)
I am developing an application using C# that will be able to send email using Microsoft Graph API. My main intention is that using this application, different users from different companies (i.e. different email domains) will be able to send emails. I am providing details of what I have done till now. Suppose my company’s email domain is email address removed for privacy reasons.The Azure admin of my company has registered an application through Azure App registration under multi-tenant option. As this is a desktop application, we are using Redirect URI as default – https://login.microsoftonline.com/common/oauth2/nativeclientMy company’s azure admin (email address removed for privacy reasons) is the owner of the application.Delegated permission for Microsoft Graph API User.Read and Mail.Send is added. In the code, I have used clientID from the Azure App registration page and tenantID as common Then I use AcquireTokenInteractive() to acquire token interactively from user. And then sending the mail – So my question is, when someone from other domain tries to send email using this application, he/she is getting this window asking for approval for access token – So, what happens when the user press request for approval? –Does it trigger an email to xyz company azure admin for approval?Or xyz azure admin need to approve the request for the requested user from their azure ad admin page?Is Azure Admin access is absolutely necessary for this?Lastly, can you please let me know what is the best way to handle this scenario i.e. what settings or coding to be done so that different user from different companies (i.e. different domain like xyz.co.in) can send email using my application (registered in azure AD by my organization email address removed for privacy reasons) Read More
Aligning Dates on a resume on “Career Summary Section” NOT “Career History Section”
Dear Friends,
I am not great at word except for writing documents or doing few things. I have a career spanning across 20 years and as I can’t put all my experience in word doc as it will become a mini book.
So I was trying to put that in summary the organization with the dates associated. It will look something like below:
What ever I do I can’t get the dates aligned properly, which makes my resume look and feel absurd. Any suggestions to fix this or better way of representing the summary will be greatful.
Thanks,
Amit
Dear Friends, I am not great at word except for writing documents or doing few things. I have a career spanning across 20 years and as I can’t put all my experience in word doc as it will become a mini book. So I was trying to put that in summary the organization with the dates associated. It will look something like below:What ever I do I can’t get the dates aligned properly, which makes my resume look and feel absurd. Any suggestions to fix this or better way of representing the summary will be greatful.Thanks,Amit Read More
Basic Authentication
Hello
Basic Authentication has been disabled in Outlook.
All my security cameras use basic authentication and cannot be upgraded.
Is there a work-around?
Thanks
Hello Basic Authentication has been disabled in Outlook.All my security cameras use basic authentication and cannot be upgraded.Is there a work-around? Thanks Read More
Issue with Accessing Custom Copilot
Hi All,
I have been experimenting with custom copilots recently and am having an issue. I publish the copilot, and configure it for Microsoft Teams channel, but when I click “Open Copilot” or copy the link and click it, it tries to open it in the Teams app, but cannot. It says “This app cannot be found.”
Any idea what is causing this? Did I skip a step? Is it a permissions issue?
Thanks
Hi All, I have been experimenting with custom copilots recently and am having an issue. I publish the copilot, and configure it for Microsoft Teams channel, but when I click “Open Copilot” or copy the link and click it, it tries to open it in the Teams app, but cannot. It says “This app cannot be found.”Any idea what is causing this? Did I skip a step? Is it a permissions issue? Thanks Read More
See what’s possible with Copilot in Excel (part 7)
Hi everyone, over the last few weeks we have had a series of posts to show you some of the things that are possible to do with Copilot in Excel. This week, we will showcase how Copilot in Excel can help create a formula to calculate distinct values.
In this example, we are given a table of event locations and we’d like to figure out a formula to count each distinct location.
Given the values that are returned, let’s find out how many location are listed:
How many distinct locations are there?
Analyzed data in B2:C156 returns:
Distinct Count of Location
50
Copilot said:
There are 50 distinct locations.
Copilot returns an answer of 50, but I would like to have a formula that updates as the list changes. A coworker suggested the formula below, but I don’t understand it. I ask copilot:
A coworker gave me this formula to calculate the distinct locations, can you tell me how it works: =SUM(–(FREQUENCY(MATCH(C:C, C:C, 0), MATCH(C:C, C:C, 0)) > 0))
This formula calculates the number of distinct locations in column C. Here’s how it works:
MATCH(C:C, C:C, 0): This part of the formula creates an array of the positions of each value in column C. The 0 indicates an exact match.
FREQUENCY(MATCH(C:C, C:C, 0), MATCH(C:C, C:C, 0)): The FREQUENCY function is used to count the number of times each value appears in the array created by the MATCH function. It returns an array where each element represents the frequency of the corresponding value.
FREQUENCY(…) > 0: This part of the formula creates a boolean array where each element is TRUE if the corresponding frequency is greater than 0, and FALSE otherwise.
–(FREQUENCY(…) > 0): The double unary operator (–) converts the boolean array into an array of 1s and 0s, where TRUE becomes 1 and FALSE becomes 0.
SUM(…): Finally, the SUM function adds up the array of 1s and 0s, giving the total count of distinct locations.
I understand the formula, but it seems overly complicated. I’d like to see if Copilot can do better. I ask:
Can you simplify the formula?
Yes, I can simplify the formula. Here is a more straightforward way to count distinct locations using the UNIQUE and COUNTA functions:
=COUNTA(UNIQUE(Table19[Location]))
That is much simpler! I copy the formula from the copilot pane and copy into my workbook. Now when I make changes to the table, the unique location count updates automatically.
Here are some additional examples from the last six weeks if you missed them:
Copilot in Excel examples for the week of August 12th
Copilot in Excel examples for the week of August 19th
Copilot in Excel examples for the week of August 26th
Copilot in Excel examples for the week of September 3rd
Copilot in Excel examples for the week of September 9th
Copilot in Excel examples for the week of September 16th
Stay tuned,
Microsoft Excel Team
*Disclaimer: If you try these types of prompts and they do not work as expected, it is most likely due to our gradual feature rollout process. Please try again in a few weeks.
Microsoft Tech Community – Latest Blogs –Read More
Fonts
Why, oh WHY ???
I THOUGHT Courier was “equal-spaced”, i.e. every character had the same width and height.
BUT . . .
When I put this in a WORD doc, using Courier, the lines do not “match up”
[O.K. – THIS WebSite deletes spaces ]
James = Eliza Joseph = Elizabeth
Soames │ Desanges Gilstrap │ Welsh
1771- │ 1785- 1785- │ 1789-
-1863 │ -1872 -1869 │ -1826
│ │
└─────┐ ┌─────┘
│ │
Arthur = Anna Amelia
Soames │ Gilstrap
1816-1894 │ 1823-1900
│
How do I overcome this ?
Why, oh WHY ??? I THOUGHT Courier was “equal-spaced”, i.e. every character had the same width and height. BUT . . . When I put this in a WORD doc, using Courier, the lines do not “match up” [O.K. – THIS WebSite deletes spaces ] James = Eliza Joseph = Elizabeth Soames │ Desanges Gilstrap │ Welsh 1771- │ 1785- 1785- │ 1789- -1863 │ -1872 -1869 │ -1826 │ │ └─────┐ ┌─────┘ │ │ Arthur = Anna Amelia Soames │ Gilstrap 1816-1894 │ 1823-1900 │ How do I overcome this ? Read More
Security settings management is available for multi-tenant environments in Microsoft Defender XDR
Several months ago, we released device security settings management within Microsoft Defender XDR. This experience enables security administrators to configure Microsoft Defender for Endpoint security settings for devices on all platforms (including Windows, Linux, and Mac) without having to leave the Defender portal. The streamlined portal experience breaks down the wall between Security and IT teams by presenting a shared view for both, making it easier for security administrators to strengthen the security posture of their devices.
Security administrators can now drive even greater efficiencies with simplified security settings management supporting multi-tenancy environments that are common to large enterprises and managed services security providers (MSSPs). The multi-tenant view in the Defender XDR portal (Multi-tenant management in Microsoft Defender XDR – Microsoft Defender XDR | Microsoft Learn) provides security administrators a consolidated view of all security policies across their entire organization, including all tenants’ policies, without needing to switch portals. To access this page, navigate to Endpoints > Configuration Management > Endpoint Security Policies.
Additionally, security administrators can create, edit, or delete policies within the context of the specific tenant centrally via the unified aggregated view.
From the Endpoint Security Policies page, a security administrator can search for a specific policy for all their tenants, using the Search function.
To manage security settings for multiple tenants in the multi-tenant view in Defender XDR portal, security administrators must follow all the prerequisites to configure security settings for a single tenant for each of their tenants (for more details please see: Use Intune to manage Microsoft Defender settings on devices that aren’t enrolled with Intune | Microsoft Learn). This includes the following role-based access control requirements:
For Microsoft Defender, use the security administrator role (or custom role with security configuration management permissions scoped to all devices)
For Microsoft Intune, use the Endpoint security manager role
Additionally, the devices in each Defender tenant must be affiliated with the corresponding Entra tenant
This experience does not currently support Microsoft Defender for Business tenants.
For more information and guidance, please visit: Endpoint security policies in multitenant management – Microsoft Defender XDR | Microsoft Learn
Microsoft Tech Community – Latest Blogs –Read More
PostgreSQL 17 Preview on Azure Postgres Flexible Server
We are thrilled to announce the preview release of PostgreSQL 17 on Azure Database for PostgreSQL Flexible Server! This release brings a host of new features and enhancements that promise to elevate your PostgreSQL experience. Our goal with this preview is to provide an opportunity for early testing into the new capabilities of PostgreSQL 17^ and enable customers to start testing these features before we transition into general availability.
What’s New in PostgreSQL 17?
PostgreSQL 17 continues the tradition of innovation with several key features aimed at improving database performance, manageability, and developer experience. Here are some of the highlights:
Getting Insights into Memory Usage via EXPLAIN: PostgreSQL 17 introduces an enhancement to the EXPLAIN command that reports the memory usage of the query planner during the preparation of execution plans. This information helps identify queries that consume excessive memory during the planning phase, aiding in query optimization and resource management.
— For example:
EXPLAIN ANALYZE SELECT * FROM my_table WHERE id < 100;
— The new EXPLAIN output now includes a line like:
Planning Memory Usage: 10,240 kB
Improvements to the Vacuum Process: Say goodbye to bloat! The enhanced vacuum process in PostgreSQL 17 ensures better space management and less interference with concurrent transactions, which means smoother database operations.
Enhanced JSON Functions: PostgreSQL 17 introduces new capabilities to simplify how you work with JSON data, including support for the JSON_TABLE function. This function allows you to convert JSON data directly into a relational table format, making it effortless to query and analyze JSON data using standard SQL without additional transformations.
— For example, say we have a JSON array that lists service regions and their availability:
SELECT *
FROM json_table(
‘[
{“region”: “East US”, “services”: {“compute”: “Available”, “database”: “Limited”}},
{“region”: “West Europe”, “services”: {“compute”: “Available”, “database”: “Available”}},
{“region”: “Southeast Asia”, “services”: {“compute”: “Limited”, “database”: “Available”}}
]’,
‘$[*]’
COLUMNS (
region_name TEXT PATH ‘$.region’,
compute_status TEXT PATH ‘$.services.compute’,
database_status TEXT PATH ‘$.services.database’
)
) AS region_info;
— This query will produce the following output:
| region_name | compute_status | database_status |
| ————– | ————– | ————— |
| East US | Available | Limited |
| West Europe | Available | Available |
| Southeast Asia | Limited | Available |
Dynamic Logical Replication: With support for dynamically changing the replication set without restarting or reconfiguring, PostgreSQL 17 simplifies the process of managing logical replication and enables more flexibility for your replication strategy.– For instance, you can now use:
ALTER PUBLICATION my_publication ADD TABLE new_table;
These are just a few of the exciting features introduced in PostgreSQL 17, and we can’t wait for you to try them out!
Celebrating Azure Postgres Contributions to PostgreSQL 17
The Azure Postgres team made 410 commits to the PostgreSQL 17 release, focusing on key improvements like I/O combining, query planner optimization, memory usage reduction, and better performance for partitioned tables. These contributions help make PostgreSQL 17 faster and more efficient, ensuring PostgreSQL delivers the best experience with the latest community innovations. To learn more about Microsoft’s contributions to the PostgreSQL open-source community, check out our blog: What’s new with Postgres at Microsoft, 2024 edition.
Roadmap and What’s Next
This preview release is just the beginning. Our team is actively working on providing Major Version Upgrade support for PostgreSQL 17, with the preview expected early next year and general availability soon after. Our goal is to ensure that customers can seamlessly upgrade to PostgreSQL 17 without downtime, leveraging the latest features and performance improvements.
We encourage you to try out PostgreSQL 17 on Azure Database for PostgreSQL Flexible Server and share your feedback by reaching out to us at AskAzureDBforPostgreSQL@microsoft.com. Stay tuned for more updates as we bring you closer to general availability!
^ Postgres 17 preview is available in “East Asia” starting immediately with more regions coming soon.
Microsoft Tech Community – Latest Blogs –Read More
Learn about HeyTaco’s Microsoft 365 partner solution in Microsoft AppSource
Microsoft 365 lets you create, share, and collaborate all in one place with your favorite apps. Learn about this offer from high-performing Microsoft 365 partner HeyTaco on Microsoft AppSource:
HeyTaco: HeyTaco boosts employee connections on Microsoft Teams by providing an easy and fun way for remote team members to recognize and celebrate each other’s contributions in real-time. With HeyTaco, teams foster a positive and inclusive culture by making gratitude and recognition part of the daily workflow, bridging the gap often felt in remote settings.
Microsoft Tech Community – Latest Blogs –Read More
About the DeLong test
Dear Professors,
I apologize for bothering you during your busy schedules. We have conducted the program described below, reading three files and performing ROC analysis through machine learning to calculate three AUCs. We have attempted to create a program to demonstrate the statistical significance of the differences among these AUCs, but despite multiple efforts, we have encountered errors that prevent progress. Could you please help us revise the program? I am attaching a program below. I would greatly appreciate it if you could add the necessary modifications to it. I am having a lot of trouble implementing the DeLong test in the program. Thank you very much for your assistance.Thank you very much for your assistance.
Best regards,
% CSVファイルのパスを指定
filePaths = {‘C:Usersrms56Desktop1-491B.csv’, …
‘C:Usersrms56Desktop1-491C.csv’, …
‘C:Usersrms56Desktop1-491D.csv’};
% X と y を格納するための cell 配列を作成
X_all = cell(3, 1); % 特徴量 X 用の cell 配列
y_all = cell(3, 1); % ラベル y 用の cell 配列
% 3つのファイルを順番に読み込み、X と y に割り当てる
for i = 1:3
% CSVファイルの読み込み
data = readmatrix(filePaths{i});
% 各ファイルに応じて X と y の列を指定
if i == 1 % ‘1-491B.csv’: 3列目までがX、4列目がY
X_all{i} = data(:, 1:3); % 1~3列目を X に設定
y_all{i} = data(:, 4); % 4列目を Y に設定
elseif i == 2 % ‘1-491C.csv’: 6列目までがX、7列目がY
X_all{i} = data(:, 1:6); % 1~6列目を X に設定
y_all{i} = data(:, 7); % 7列目を Y に設定
elseif i == 3 % ‘1-491D.csv’: 3列目までがX、4列目がY
X_all{i} = data(:, 1:3); % 1~3列目を X に設定
y_all{i} = data(:, 4); % 4列目を Y に設定
end
end
% ファイルごとの解析をループで実行
for fileIndex = 1:3
% ファイルに対応するデータを取得
X = X_all{fileIndex}; % 特徴量
y = y_all{fileIndex}; % ラベル
% クロスバリデーションの設定
k = 5; % フォールド数
cv = cvpartition(y, ‘KFold’, k); % クロスバリデーションの分割
accuracy = zeros(k, 1); % 各フォールドの精度を格納する配列
% 各フォールドごとにトレーニングとテストを実行
for i = 1:k
trainIdx = training(cv, i);
testIdx = test(cv, i);
% データの分割
XTrain = X(trainIdx, :);
yTrain = y(trainIdx, :);
XTest = X(testIdx, :);
yTest = y(testIdx, :);
% SVMモデルのトレーニング
model = fitcsvm(XTrain, yTrain, …
‘KernelFunction’, ‘polynomial’, …
‘PolynomialOrder’, 2, …
‘KernelScale’, ‘auto’, …
‘BoxConstraint’, 1, …
‘Standardize’, true);
% モデルを使用してテストセットを予測
[predictions, score] = predict(model, XTest);
% 現在のフォールドの精度を計算
accuracy(i) = sum(predictions == yTest) / length(yTest);
fprintf(‘ファイル %d – Fold %d Accuracy: %.2f%%n’, fileIndex, i, accuracy(i) * 100);
end
% 全フォールドの平均精度を計算
averageAccuracy = mean(accuracy);
fprintf(‘ファイル %d – Average Accuracy: %.2f%%n’, fileIndex, averageAccuracy * 100);
% ROC曲線とAUCの計算
[~, ~, ~, AUC_final] = perfcurve(yTest, score(:, 2), 1);
% ブートストラップ法で信頼区間を計算
nBoot = 1000; % ブートストラップの反復回数
[AUC_bootstrap, CI_final] = bootstrapAUC(yTest, score(:, 2), nBoot);
% 混同行列の計算
confusionMatrix_final = confusionmat(yTest, predictions);
tn = confusionMatrix_final(1, 1);
fp = confusionMatrix_final(1, 2);
fn = confusionMatrix_final(2, 1);
tp = confusionMatrix_final(2, 2);
% 指標の計算
sensitivity_final = tp / (tp + fn);
specificity_final = tn / (tn + fp);
ppv_final = tp / (tp + fp);
npv_final = tn / (tn + fn);
accuracy_final = (tp + tn) / sum(confusionMatrix_final(:));
% 結果の表示
fprintf(‘ファイル %d – 最終的なAUC: %.2fn’, fileIndex, AUC_final);
fprintf(‘ファイル %d – ブートストラップ法による95%%信頼区間: [%.2f, %.2f]n’, fileIndex, CI_final(1), CI_final(2));
fprintf(‘感度: %.2fn’, sensitivity_final);
fprintf(‘特異度: %.2fn’, specificity_final);
fprintf(‘陽性的中率: %.2fn’, ppv_final);
fprintf(‘陰性的中率: %.2fn’, npv_final);
fprintf(‘診断精度: %.2fn’, accuracy_final);
% ROC曲線を描画
figure;
plot(Xroc, Yroc, ‘b-‘, ‘LineWidth’, 2);
xlabel(‘特異度’);
ylabel(‘感度’);
title(sprintf(‘ファイル %d – ROC曲線’, fileIndex));
grid on;
% 混同行列を描画
figure;
confusionchart(confusionMatrix_final, {‘Negative’, ‘Positive’}, ‘RowSummary’, ‘row-normalized’, …
‘ColumnSummary’, ‘column-normalized’);
title(sprintf(‘ファイル %d – 混同行列’, fileIndex));
end
% ブートストラップ法によるAUCと信頼区間を計算する関数
function [AUC, CI] = bootstrapAUC(yTrue, scores, nBoot)
% 初期化
AUC = zeros(nBoot, 1);
for i = 1:nBoot
idx = randi(length(yTrue), [length(yTrue), 1]); % リプレースメントで再サンプリング
yBoot = yTrue(idx);
scoresBoot = scores(idx);
[~, ~, ~, AUC(i)] = perfcurve(yBoot, scoresBoot, 1); % AUC計算
end
% 信頼区間の計算
CI = prctile(AUC, [2.5 97.5]); % 95%信頼区間
endDear Professors,
I apologize for bothering you during your busy schedules. We have conducted the program described below, reading three files and performing ROC analysis through machine learning to calculate three AUCs. We have attempted to create a program to demonstrate the statistical significance of the differences among these AUCs, but despite multiple efforts, we have encountered errors that prevent progress. Could you please help us revise the program? I am attaching a program below. I would greatly appreciate it if you could add the necessary modifications to it. I am having a lot of trouble implementing the DeLong test in the program. Thank you very much for your assistance.Thank you very much for your assistance.
Best regards,
% CSVファイルのパスを指定
filePaths = {‘C:Usersrms56Desktop1-491B.csv’, …
‘C:Usersrms56Desktop1-491C.csv’, …
‘C:Usersrms56Desktop1-491D.csv’};
% X と y を格納するための cell 配列を作成
X_all = cell(3, 1); % 特徴量 X 用の cell 配列
y_all = cell(3, 1); % ラベル y 用の cell 配列
% 3つのファイルを順番に読み込み、X と y に割り当てる
for i = 1:3
% CSVファイルの読み込み
data = readmatrix(filePaths{i});
% 各ファイルに応じて X と y の列を指定
if i == 1 % ‘1-491B.csv’: 3列目までがX、4列目がY
X_all{i} = data(:, 1:3); % 1~3列目を X に設定
y_all{i} = data(:, 4); % 4列目を Y に設定
elseif i == 2 % ‘1-491C.csv’: 6列目までがX、7列目がY
X_all{i} = data(:, 1:6); % 1~6列目を X に設定
y_all{i} = data(:, 7); % 7列目を Y に設定
elseif i == 3 % ‘1-491D.csv’: 3列目までがX、4列目がY
X_all{i} = data(:, 1:3); % 1~3列目を X に設定
y_all{i} = data(:, 4); % 4列目を Y に設定
end
end
% ファイルごとの解析をループで実行
for fileIndex = 1:3
% ファイルに対応するデータを取得
X = X_all{fileIndex}; % 特徴量
y = y_all{fileIndex}; % ラベル
% クロスバリデーションの設定
k = 5; % フォールド数
cv = cvpartition(y, ‘KFold’, k); % クロスバリデーションの分割
accuracy = zeros(k, 1); % 各フォールドの精度を格納する配列
% 各フォールドごとにトレーニングとテストを実行
for i = 1:k
trainIdx = training(cv, i);
testIdx = test(cv, i);
% データの分割
XTrain = X(trainIdx, :);
yTrain = y(trainIdx, :);
XTest = X(testIdx, :);
yTest = y(testIdx, :);
% SVMモデルのトレーニング
model = fitcsvm(XTrain, yTrain, …
‘KernelFunction’, ‘polynomial’, …
‘PolynomialOrder’, 2, …
‘KernelScale’, ‘auto’, …
‘BoxConstraint’, 1, …
‘Standardize’, true);
% モデルを使用してテストセットを予測
[predictions, score] = predict(model, XTest);
% 現在のフォールドの精度を計算
accuracy(i) = sum(predictions == yTest) / length(yTest);
fprintf(‘ファイル %d – Fold %d Accuracy: %.2f%%n’, fileIndex, i, accuracy(i) * 100);
end
% 全フォールドの平均精度を計算
averageAccuracy = mean(accuracy);
fprintf(‘ファイル %d – Average Accuracy: %.2f%%n’, fileIndex, averageAccuracy * 100);
% ROC曲線とAUCの計算
[~, ~, ~, AUC_final] = perfcurve(yTest, score(:, 2), 1);
% ブートストラップ法で信頼区間を計算
nBoot = 1000; % ブートストラップの反復回数
[AUC_bootstrap, CI_final] = bootstrapAUC(yTest, score(:, 2), nBoot);
% 混同行列の計算
confusionMatrix_final = confusionmat(yTest, predictions);
tn = confusionMatrix_final(1, 1);
fp = confusionMatrix_final(1, 2);
fn = confusionMatrix_final(2, 1);
tp = confusionMatrix_final(2, 2);
% 指標の計算
sensitivity_final = tp / (tp + fn);
specificity_final = tn / (tn + fp);
ppv_final = tp / (tp + fp);
npv_final = tn / (tn + fn);
accuracy_final = (tp + tn) / sum(confusionMatrix_final(:));
% 結果の表示
fprintf(‘ファイル %d – 最終的なAUC: %.2fn’, fileIndex, AUC_final);
fprintf(‘ファイル %d – ブートストラップ法による95%%信頼区間: [%.2f, %.2f]n’, fileIndex, CI_final(1), CI_final(2));
fprintf(‘感度: %.2fn’, sensitivity_final);
fprintf(‘特異度: %.2fn’, specificity_final);
fprintf(‘陽性的中率: %.2fn’, ppv_final);
fprintf(‘陰性的中率: %.2fn’, npv_final);
fprintf(‘診断精度: %.2fn’, accuracy_final);
% ROC曲線を描画
figure;
plot(Xroc, Yroc, ‘b-‘, ‘LineWidth’, 2);
xlabel(‘特異度’);
ylabel(‘感度’);
title(sprintf(‘ファイル %d – ROC曲線’, fileIndex));
grid on;
% 混同行列を描画
figure;
confusionchart(confusionMatrix_final, {‘Negative’, ‘Positive’}, ‘RowSummary’, ‘row-normalized’, …
‘ColumnSummary’, ‘column-normalized’);
title(sprintf(‘ファイル %d – 混同行列’, fileIndex));
end
% ブートストラップ法によるAUCと信頼区間を計算する関数
function [AUC, CI] = bootstrapAUC(yTrue, scores, nBoot)
% 初期化
AUC = zeros(nBoot, 1);
for i = 1:nBoot
idx = randi(length(yTrue), [length(yTrue), 1]); % リプレースメントで再サンプリング
yBoot = yTrue(idx);
scoresBoot = scores(idx);
[~, ~, ~, AUC(i)] = perfcurve(yBoot, scoresBoot, 1); % AUC計算
end
% 信頼区間の計算
CI = prctile(AUC, [2.5 97.5]); % 95%信頼区間
end Dear Professors,
I apologize for bothering you during your busy schedules. We have conducted the program described below, reading three files and performing ROC analysis through machine learning to calculate three AUCs. We have attempted to create a program to demonstrate the statistical significance of the differences among these AUCs, but despite multiple efforts, we have encountered errors that prevent progress. Could you please help us revise the program? I am attaching a program below. I would greatly appreciate it if you could add the necessary modifications to it. I am having a lot of trouble implementing the DeLong test in the program. Thank you very much for your assistance.Thank you very much for your assistance.
Best regards,
% CSVファイルのパスを指定
filePaths = {‘C:Usersrms56Desktop1-491B.csv’, …
‘C:Usersrms56Desktop1-491C.csv’, …
‘C:Usersrms56Desktop1-491D.csv’};
% X と y を格納するための cell 配列を作成
X_all = cell(3, 1); % 特徴量 X 用の cell 配列
y_all = cell(3, 1); % ラベル y 用の cell 配列
% 3つのファイルを順番に読み込み、X と y に割り当てる
for i = 1:3
% CSVファイルの読み込み
data = readmatrix(filePaths{i});
% 各ファイルに応じて X と y の列を指定
if i == 1 % ‘1-491B.csv’: 3列目までがX、4列目がY
X_all{i} = data(:, 1:3); % 1~3列目を X に設定
y_all{i} = data(:, 4); % 4列目を Y に設定
elseif i == 2 % ‘1-491C.csv’: 6列目までがX、7列目がY
X_all{i} = data(:, 1:6); % 1~6列目を X に設定
y_all{i} = data(:, 7); % 7列目を Y に設定
elseif i == 3 % ‘1-491D.csv’: 3列目までがX、4列目がY
X_all{i} = data(:, 1:3); % 1~3列目を X に設定
y_all{i} = data(:, 4); % 4列目を Y に設定
end
end
% ファイルごとの解析をループで実行
for fileIndex = 1:3
% ファイルに対応するデータを取得
X = X_all{fileIndex}; % 特徴量
y = y_all{fileIndex}; % ラベル
% クロスバリデーションの設定
k = 5; % フォールド数
cv = cvpartition(y, ‘KFold’, k); % クロスバリデーションの分割
accuracy = zeros(k, 1); % 各フォールドの精度を格納する配列
% 各フォールドごとにトレーニングとテストを実行
for i = 1:k
trainIdx = training(cv, i);
testIdx = test(cv, i);
% データの分割
XTrain = X(trainIdx, :);
yTrain = y(trainIdx, :);
XTest = X(testIdx, :);
yTest = y(testIdx, :);
% SVMモデルのトレーニング
model = fitcsvm(XTrain, yTrain, …
‘KernelFunction’, ‘polynomial’, …
‘PolynomialOrder’, 2, …
‘KernelScale’, ‘auto’, …
‘BoxConstraint’, 1, …
‘Standardize’, true);
% モデルを使用してテストセットを予測
[predictions, score] = predict(model, XTest);
% 現在のフォールドの精度を計算
accuracy(i) = sum(predictions == yTest) / length(yTest);
fprintf(‘ファイル %d – Fold %d Accuracy: %.2f%%n’, fileIndex, i, accuracy(i) * 100);
end
% 全フォールドの平均精度を計算
averageAccuracy = mean(accuracy);
fprintf(‘ファイル %d – Average Accuracy: %.2f%%n’, fileIndex, averageAccuracy * 100);
% ROC曲線とAUCの計算
[~, ~, ~, AUC_final] = perfcurve(yTest, score(:, 2), 1);
% ブートストラップ法で信頼区間を計算
nBoot = 1000; % ブートストラップの反復回数
[AUC_bootstrap, CI_final] = bootstrapAUC(yTest, score(:, 2), nBoot);
% 混同行列の計算
confusionMatrix_final = confusionmat(yTest, predictions);
tn = confusionMatrix_final(1, 1);
fp = confusionMatrix_final(1, 2);
fn = confusionMatrix_final(2, 1);
tp = confusionMatrix_final(2, 2);
% 指標の計算
sensitivity_final = tp / (tp + fn);
specificity_final = tn / (tn + fp);
ppv_final = tp / (tp + fp);
npv_final = tn / (tn + fn);
accuracy_final = (tp + tn) / sum(confusionMatrix_final(:));
% 結果の表示
fprintf(‘ファイル %d – 最終的なAUC: %.2fn’, fileIndex, AUC_final);
fprintf(‘ファイル %d – ブートストラップ法による95%%信頼区間: [%.2f, %.2f]n’, fileIndex, CI_final(1), CI_final(2));
fprintf(‘感度: %.2fn’, sensitivity_final);
fprintf(‘特異度: %.2fn’, specificity_final);
fprintf(‘陽性的中率: %.2fn’, ppv_final);
fprintf(‘陰性的中率: %.2fn’, npv_final);
fprintf(‘診断精度: %.2fn’, accuracy_final);
% ROC曲線を描画
figure;
plot(Xroc, Yroc, ‘b-‘, ‘LineWidth’, 2);
xlabel(‘特異度’);
ylabel(‘感度’);
title(sprintf(‘ファイル %d – ROC曲線’, fileIndex));
grid on;
% 混同行列を描画
figure;
confusionchart(confusionMatrix_final, {‘Negative’, ‘Positive’}, ‘RowSummary’, ‘row-normalized’, …
‘ColumnSummary’, ‘column-normalized’);
title(sprintf(‘ファイル %d – 混同行列’, fileIndex));
end
% ブートストラップ法によるAUCと信頼区間を計算する関数
function [AUC, CI] = bootstrapAUC(yTrue, scores, nBoot)
% 初期化
AUC = zeros(nBoot, 1);
for i = 1:nBoot
idx = randi(length(yTrue), [length(yTrue), 1]); % リプレースメントで再サンプリング
yBoot = yTrue(idx);
scoresBoot = scores(idx);
[~, ~, ~, AUC(i)] = perfcurve(yBoot, scoresBoot, 1); % AUC計算
end
% 信頼区間の計算
CI = prctile(AUC, [2.5 97.5]); % 95%信頼区間
end delong test MATLAB Answers — New Questions
USRP X310 Validate Radio Setup Error
I used ‘Wireless testbench Support package for NI USRP Radios’ for configuring my NI USRP-2954R, and I met the following error in the validate tap.
How can I solve this problem?I used ‘Wireless testbench Support package for NI USRP Radios’ for configuring my NI USRP-2954R, and I met the following error in the validate tap.
How can I solve this problem? I used ‘Wireless testbench Support package for NI USRP Radios’ for configuring my NI USRP-2954R, and I met the following error in the validate tap.
How can I solve this problem? toolbox, usrp, x310 MATLAB Answers — New Questions
How can I extract heart rate and respiration rate from radar signals?
Following is my matlab code. Two radar transmitters and on receiver is used. I want to combine the correlation results and extract heart beat and respiration rate. Any help?
% Initialize variables
Fs = 100; % Sampling frequency
duration = 60; % Duration of the recording in seconds
t = 0:1/Fs:duration-1/Fs; % Time vector
N = length(t); % Number of samples
f = (0:N-1)*(Fs/N); % Frequency vector
num_iterations = 10; % Number of iterations to run the code
% Initialize arrays to store heart rate and respiration rate
HR_radar = zeros(1,num_iterations);
RR_radar = zeros(1,num_iterations);
HR_ecg = zeros(1,num_iterations);
RR_ecg = zeros(1,num_iterations);
for i = 1:num_iterations
% Generate a synthetic UWB radar signal
tx1 = 0.5*sin(2*pi*1*t); % Transmitter 1 signal
tx2 = 0.5*sin(2*pi*1*t + pi); % Transmitter 2 signal
rx = tx1 + tx2; % Receiver signal
% Add noise to the receiver signal
rx = rx + 0.1*randn(size(rx));
% Filter the receiver signal to remove noise
[b,a] = butter(2, [0.5 5]/(Fs/2), ‘bandpass’);
rx_filtered = filtfilt(b,a,rx);
% Perform cross-correlation between the transmitter signals and the receiver signal
corr1 = xcorr(tx1, rx_filtered);
corr2 = xcorr(tx2, rx_filtered);
% CombineFollowing is my matlab code. Two radar transmitters and on receiver is used. I want to combine the correlation results and extract heart beat and respiration rate. Any help?
% Initialize variables
Fs = 100; % Sampling frequency
duration = 60; % Duration of the recording in seconds
t = 0:1/Fs:duration-1/Fs; % Time vector
N = length(t); % Number of samples
f = (0:N-1)*(Fs/N); % Frequency vector
num_iterations = 10; % Number of iterations to run the code
% Initialize arrays to store heart rate and respiration rate
HR_radar = zeros(1,num_iterations);
RR_radar = zeros(1,num_iterations);
HR_ecg = zeros(1,num_iterations);
RR_ecg = zeros(1,num_iterations);
for i = 1:num_iterations
% Generate a synthetic UWB radar signal
tx1 = 0.5*sin(2*pi*1*t); % Transmitter 1 signal
tx2 = 0.5*sin(2*pi*1*t + pi); % Transmitter 2 signal
rx = tx1 + tx2; % Receiver signal
% Add noise to the receiver signal
rx = rx + 0.1*randn(size(rx));
% Filter the receiver signal to remove noise
[b,a] = butter(2, [0.5 5]/(Fs/2), ‘bandpass’);
rx_filtered = filtfilt(b,a,rx);
% Perform cross-correlation between the transmitter signals and the receiver signal
corr1 = xcorr(tx1, rx_filtered);
corr2 = xcorr(tx2, rx_filtered);
% Combine Following is my matlab code. Two radar transmitters and on receiver is used. I want to combine the correlation results and extract heart beat and respiration rate. Any help?
% Initialize variables
Fs = 100; % Sampling frequency
duration = 60; % Duration of the recording in seconds
t = 0:1/Fs:duration-1/Fs; % Time vector
N = length(t); % Number of samples
f = (0:N-1)*(Fs/N); % Frequency vector
num_iterations = 10; % Number of iterations to run the code
% Initialize arrays to store heart rate and respiration rate
HR_radar = zeros(1,num_iterations);
RR_radar = zeros(1,num_iterations);
HR_ecg = zeros(1,num_iterations);
RR_ecg = zeros(1,num_iterations);
for i = 1:num_iterations
% Generate a synthetic UWB radar signal
tx1 = 0.5*sin(2*pi*1*t); % Transmitter 1 signal
tx2 = 0.5*sin(2*pi*1*t + pi); % Transmitter 2 signal
rx = tx1 + tx2; % Receiver signal
% Add noise to the receiver signal
rx = rx + 0.1*randn(size(rx));
% Filter the receiver signal to remove noise
[b,a] = butter(2, [0.5 5]/(Fs/2), ‘bandpass’);
rx_filtered = filtfilt(b,a,rx);
% Perform cross-correlation between the transmitter signals and the receiver signal
corr1 = xcorr(tx1, rx_filtered);
corr2 = xcorr(tx2, rx_filtered);
% Combine remote health monitoring MATLAB Answers — New Questions
Custom Built Glossary and Training Manual, with search feature
Hello,
I’m trying to locate an App in Teams that serves as a training and resource tool. Essentially I want the user to be able to search for a keyword that we use within our business, and then the App return with a selection of articles or links to files within Teams that have information relating to that topic, all of which will be writted from the ground up.
For example: If I wanted to search for the word ‘Job Sheet’, the app would return information that has this particular reference either in the body of the document, or as a tag/meta tag/keyword that I assign when writing the documents up.
The idea is to input all the relevant data that relates to our line of work and then have the users use this tool for research.
If the App has a way to embed images within itself (screenshots that show any provesses) or video files, or link to PDF files that are stored on our local network all the better.
Thanks
Dan
Hello, I’m trying to locate an App in Teams that serves as a training and resource tool. Essentially I want the user to be able to search for a keyword that we use within our business, and then the App return with a selection of articles or links to files within Teams that have information relating to that topic, all of which will be writted from the ground up.For example: If I wanted to search for the word ‘Job Sheet’, the app would return information that has this particular reference either in the body of the document, or as a tag/meta tag/keyword that I assign when writing the documents up. The idea is to input all the relevant data that relates to our line of work and then have the users use this tool for research. If the App has a way to embed images within itself (screenshots that show any provesses) or video files, or link to PDF files that are stored on our local network all the better. Thanks Dan Read More
How to get SC-100 Certificate
I recently(27th Sep 2024) completed my Certification for SC-100 Exam and Passed. As usual I expected to get the certificate on my Certifications Profile but I only see the Link to Peason’ Vue portal.
How can I get the Certificate or it’s tied to another cert that I must complete
I recently(27th Sep 2024) completed my Certification for SC-100 Exam and Passed. As usual I expected to get the certificate on my Certifications Profile but I only see the Link to Peason’ Vue portal. How can I get the Certificate or it’s tied to another cert that I must complete Read More
Blog about Rule creation for emails you are in the BCC to move to other folder
Have you faced a scenario where you want to move an email you are in the BCC to specific folder but such rule does not exist out of the box, here you are the steps to do so:
Have you faced a scenario where you want to move an email you are in the BCC to specific folder but such rule does not exist out of the box, here you are the steps to do so:
Read Full Blog
Read More
Accessing Online Archives with Outlook Mobile
Following a change made to Microsoft Synchronization Technology to support the new Outlook for Windows, Outlook mobile supports access to archive mailboxes. For mailboxes enabled with an archive, the archive mailbox is listed like other mailboxes and opened in the same way. The only thing to remember is that archive items tend to be old and therefore you’ll probably have to instruct Outlook to download the items to the device.
https://office365itpros.com/2024/09/30/online-archive-outlook-mobile/
Following a change made to Microsoft Synchronization Technology to support the new Outlook for Windows, Outlook mobile supports access to archive mailboxes. For mailboxes enabled with an archive, the archive mailbox is listed like other mailboxes and opened in the same way. The only thing to remember is that archive items tend to be old and therefore you’ll probably have to instruct Outlook to download the items to the device.
https://office365itpros.com/2024/09/30/online-archive-outlook-mobile/ Read More
How do I set the threshold value on the action potential on the upward and downward slope to define width?
Hi,
I am doing action potential analysis and at the moment I am defining my threshold value manually using ginput for analysing width, however I would like to set identical y values for analysis of width of the curve. Right now, I zoom into the figure to try and set the x and y points to get the width of the AP.
My code for producing the figure and setting ginput values manually for the defined variables:
% Roksana’s script to plot .smr AP data
% 20210127
% For troubleshooting analysis – cleans the workspace
clear
close all
%Import data
load(‘C:xyz.mat’)
%Define channel to plot
data = xyz;
vm = data.values;
%scale x-axis by interval
t = linspace(0, length(vm)*data.interval,length(vm));
plot(t,vm)
xlabel(‘Time (s)’)
ylabel(‘Voltage (mV)’)
title(‘Membrane potential’)
%find max Vm value between 2 points selected on the figure
[x, y] = ginput(2);
%Report values towards AP width
xfirst = x(1,1)
xsecond = x(2,1)
%Round values for calculations of parameters
xpt1 = round(x(1));
xpt2 = round(x(2));
ypt1 = round(y(1));
ypt2 = round(y(2));
%Find a point between the first and second points on x-axis
isin = (t >= xpt1 & t <= xpt2);
%Identify the peak between the two points on the x-axis
%peak = max(vm(isin))
peak = max(vm)
%Display trough (mV); from baseline
APtrough = min(vm(isin))
%%Display AP amplitude (mV)
APamp = (peak + (ypt1*(-1)))
%%Display half-amplitude(mV)
APhalfamp = ((peak-APtrough)*0.5)
%%%Area under the curve and width values from threshold value – require zoom%%%
%pause script until button press for zooming in
zoom on;
pause ();
zoom off;
%find max Vm value between 2 points selected on the figure
[a, b] = ginput(2);
%Report values towards AP width
thresholdt1 = a(1,1)
thresholdt2 = a(2,1)
thresholdValue1 = b(1)
thresholdValue2 = b(2)
%%Display width(ms)
width = (thresholdt2 – thresholdt1)*1000 %%%%needs to be defined by threshold
%%Display half-width(ms)
APhalfwidth = (width/2)Hi,
I am doing action potential analysis and at the moment I am defining my threshold value manually using ginput for analysing width, however I would like to set identical y values for analysis of width of the curve. Right now, I zoom into the figure to try and set the x and y points to get the width of the AP.
My code for producing the figure and setting ginput values manually for the defined variables:
% Roksana’s script to plot .smr AP data
% 20210127
% For troubleshooting analysis – cleans the workspace
clear
close all
%Import data
load(‘C:xyz.mat’)
%Define channel to plot
data = xyz;
vm = data.values;
%scale x-axis by interval
t = linspace(0, length(vm)*data.interval,length(vm));
plot(t,vm)
xlabel(‘Time (s)’)
ylabel(‘Voltage (mV)’)
title(‘Membrane potential’)
%find max Vm value between 2 points selected on the figure
[x, y] = ginput(2);
%Report values towards AP width
xfirst = x(1,1)
xsecond = x(2,1)
%Round values for calculations of parameters
xpt1 = round(x(1));
xpt2 = round(x(2));
ypt1 = round(y(1));
ypt2 = round(y(2));
%Find a point between the first and second points on x-axis
isin = (t >= xpt1 & t <= xpt2);
%Identify the peak between the two points on the x-axis
%peak = max(vm(isin))
peak = max(vm)
%Display trough (mV); from baseline
APtrough = min(vm(isin))
%%Display AP amplitude (mV)
APamp = (peak + (ypt1*(-1)))
%%Display half-amplitude(mV)
APhalfamp = ((peak-APtrough)*0.5)
%%%Area under the curve and width values from threshold value – require zoom%%%
%pause script until button press for zooming in
zoom on;
pause ();
zoom off;
%find max Vm value between 2 points selected on the figure
[a, b] = ginput(2);
%Report values towards AP width
thresholdt1 = a(1,1)
thresholdt2 = a(2,1)
thresholdValue1 = b(1)
thresholdValue2 = b(2)
%%Display width(ms)
width = (thresholdt2 – thresholdt1)*1000 %%%%needs to be defined by threshold
%%Display half-width(ms)
APhalfwidth = (width/2) Hi,
I am doing action potential analysis and at the moment I am defining my threshold value manually using ginput for analysing width, however I would like to set identical y values for analysis of width of the curve. Right now, I zoom into the figure to try and set the x and y points to get the width of the AP.
My code for producing the figure and setting ginput values manually for the defined variables:
% Roksana’s script to plot .smr AP data
% 20210127
% For troubleshooting analysis – cleans the workspace
clear
close all
%Import data
load(‘C:xyz.mat’)
%Define channel to plot
data = xyz;
vm = data.values;
%scale x-axis by interval
t = linspace(0, length(vm)*data.interval,length(vm));
plot(t,vm)
xlabel(‘Time (s)’)
ylabel(‘Voltage (mV)’)
title(‘Membrane potential’)
%find max Vm value between 2 points selected on the figure
[x, y] = ginput(2);
%Report values towards AP width
xfirst = x(1,1)
xsecond = x(2,1)
%Round values for calculations of parameters
xpt1 = round(x(1));
xpt2 = round(x(2));
ypt1 = round(y(1));
ypt2 = round(y(2));
%Find a point between the first and second points on x-axis
isin = (t >= xpt1 & t <= xpt2);
%Identify the peak between the two points on the x-axis
%peak = max(vm(isin))
peak = max(vm)
%Display trough (mV); from baseline
APtrough = min(vm(isin))
%%Display AP amplitude (mV)
APamp = (peak + (ypt1*(-1)))
%%Display half-amplitude(mV)
APhalfamp = ((peak-APtrough)*0.5)
%%%Area under the curve and width values from threshold value – require zoom%%%
%pause script until button press for zooming in
zoom on;
pause ();
zoom off;
%find max Vm value between 2 points selected on the figure
[a, b] = ginput(2);
%Report values towards AP width
thresholdt1 = a(1,1)
thresholdt2 = a(2,1)
thresholdValue1 = b(1)
thresholdValue2 = b(2)
%%Display width(ms)
width = (thresholdt2 – thresholdt1)*1000 %%%%needs to be defined by threshold
%%Display half-width(ms)
APhalfwidth = (width/2) action potential analysis, threshold value MATLAB Answers — New Questions
Enabling bus sorting by name in the Simulink Type Editor
How to enable bus sorting by name in the Simulink Type Editor?How to enable bus sorting by name in the Simulink Type Editor? How to enable bus sorting by name in the Simulink Type Editor? type editor, bus, gui, bus sorting MATLAB Answers — New Questions
how to change size of simscape models
When I change Stewart platform to 10 times of the default size(such as 28cm to 280 cm) and run the model, the model fell apart and became inffective. So I’d like to know is there any parameter that I need to change to make sure this model works well when its size changes.The default size is so tiny that I can use this model directly.
I’ll appreciate it if anyone could answer my little question!
Sincerely,When I change Stewart platform to 10 times of the default size(such as 28cm to 280 cm) and run the model, the model fell apart and became inffective. So I’d like to know is there any parameter that I need to change to make sure this model works well when its size changes.The default size is so tiny that I can use this model directly.
I’ll appreciate it if anyone could answer my little question!
Sincerely, When I change Stewart platform to 10 times of the default size(such as 28cm to 280 cm) and run the model, the model fell apart and became inffective. So I’d like to know is there any parameter that I need to change to make sure this model works well when its size changes.The default size is so tiny that I can use this model directly.
I’ll appreciate it if anyone could answer my little question!
Sincerely, simscape, stewart platform, simscape multibody MATLAB Answers — New Questions