AaltoSciComp
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Help
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Welcome to Matlab Basics 2021 ###### tags: `Matlab_Basics` :::info This is an online course. - Course page + repository + info: https://version.aalto.fi/gitlab/eglerean/matlabcourse/-/tree/master/AY20212022/MatlabBasics2021 - This document: https://hackmd.io/@AaltoSciComp/MatlabBasics2021 - Archive of this document (Day1 and 2): https://hackmd.io/@AaltoSciComp/Matlab_Archive - Learning materials: https://swcarpentry.github.io/matlab-novice-inflammation/ - Dates: 22, 24, 26 November, 11:50-15:00 EET (Finnish time) - Zoom room: SENT VIA EMAIL - Course prerequisites: - Have a working copy of the most recent Matlab on your machine, or on a remote system that you can comfortably use. - Create an account at https://matlabacademy.mathworks.com/ using your institution email address to access extra content - Please note that we will record the zoom: do not switch your camera or microphone unless you intend to. - Video from Day1 at https://www.youtube.com/watch?v=MvrLgyF_QPM - You can follow our YouTube channel for similar content: https://www.youtube.com/channel/UCNErdFO1_GzSkDx0bLKWXOA ::: ### Questions from the registration form - Can we get recording of those lectures as well? - We will record the course, however this will be almost identical to what we did last year, which is already available on YouTube at https://www.youtube.com/watch?v=gbvtrJFWitU&list=PLZLVmS9rf3nORXjlO26n7Iov7i_a-s2Qs so feel free to watch those if you cannot attend to the live sessions - Can I get a certificate / credit for the course? - To get a certificate or credit, you need to complete 100% of "Matlab Fundamentals" from Matlab Academy and send a link to the Matlab Academy certificate https://matlabacademy.mathworks.com/details/matlab-fundamentals/mlbe - Can I get a certificate without the credit? - As the number of learners enrolled is very high this year, we cannot provide a certificate for those who do not finish the homeworks (see point above) - Is the course free of charge? - Yes, it is! However this course is made for learners at Aalto. Any differences specific to other organisations cannot be taken into account as we do not have the means for doing that (e.g. verifying that every organisation has access to the same version of Matlab) - Do I need an Aalto (student) account? - No, you only need a working copy of Matlab and an acount on Matlab Academy website if you plan to do the homeworks for the certificate/credit. If your organisation does not have access to Matlab license or to Matlab academy, then unfortunately we are not able to compensate for that. - Will there be any Simulink? - Unfortunately there is not enough time to cover Simulink, the best is to self learn it at: https://matlabacademy.mathworks.com/#simulink # Day 3 ## Icebreaker There are many toolboxes that are developed by other users (i.e. not made by matlab). Using your favourite search engine, can you search for a matlab toolbox in your field and paste the link here below and a tiny description? (here what other learners did last year https://hackmd.io/IG9SGM5AQia48IwKp_Hnjg?view#Icebreaker-day-2) - Toolbox to work with brain images https://www.mathworks.com/matlabcentral/fileexchange/8797-tools-for-nifti-and-analyze-image - Brain connectivity toolbox https://sites.google.com/site/bctnet/ - I used to use the [COBRA Toolbox](https://github.com/opencobra/cobratoolbox) constraint based metabolic modelling) . - Quantum Optics Toolbox https://qo.phy.auckland.ac.nz/toolbox/ - . ### Questions - Could you show again the tools found from last year? - https://hackmd.io/IG9SGM5AQia48IwKp_Hnjg?view#Icebreaker-day-2 ## Recap of Day1/2 ## Making Choices cont'd ### Questions **Remark: when using `if` clauses, try to have an explicit statement like (`if any(vectorA)`) instead of `vectorA`. It is a, more easily readable, and you won't run into the borderline situations shown in the lecture material. I.e. make clear what exactly you are testing, since otherwise bugs are much more difficult to find.** ### Exercise: Nesting https://swcarpentry.github.io/matlab-novice-inflammation/06-cond/index.html #### Results: - 1a, 2a, 3a, 1b, 2b, 3b - 1a,2a, 3a, 1b, 2b.... - 1a,2a,3a,1b,2b,3bdisp #### Code snippet (before adding if statements) ```(matlab) %PLOT_ALL Developing code to automate inflammation analysis % first we get a list of all the CSV files files = dir('data/inflammation-*.csv'); for i = 1:length(files) % we loop through each file file_name = files(i).name; % Generate string for image name img_name = replace(file_name, '.csv', '.png'); % Generate path to data files (input) and image file (output) file_name = fullfile('data',file_name); img_name = fullfile('results',img_name); % --- here goes the actual processing % 1. loading the patient data disp(['Loading data for: ' file_name]) patient_data = readmatrix(file_name); % you can use csvread % 2. making the figure with subplots figure('visible', 'off') subplot(2, 2, 1) plot(mean(patient_data, 1)) title('Average') ylabel('Inflammation') xlabel('Day') subplot(2, 2, 2) plot(max(patient_data, [], 1)) title('Max') ylabel('Inflammation') xlabel('Day') subplot(2, 2, 3) plot(min(patient_data, [], 1)) title('Min') ylabel('Inflammation') xlabel('Day') % 3. save the figure to a png file in img_name disp(['Saving figure in file: ' img_name]) print(img_name, '-dpng') close() end ``` ### Questions **Remark: If you select a larger for loop or if clause and press `ctrl+i`, matlab will auto-indent the selection. You can also auto-indent a whole file by selecting all (`ctrl+a`) and then pressing `ctrl+i` this is quite useful, since it creates a consistent way of indentation, which is useful for readability, it also ensures, that the same way for creating the indentation is used (and e.g. not a mix of tabs and spaces)** ## Creating Functions ## Exercise until 13:20 https://swcarpentry.github.io/matlab-novice-inflammation/07-func/index.html Scroll to "Concatenating in a function" Hint: you will need to start with `edit fence.m` Write here if you are done or need help - done - didn't understand even by looking at the solution - the idea is to put the variable passed in as "original" within copies of the "wrapper" variable. Both would need to be character-arrays (or strings). `strcat` concatenates (i.e. puts together) all str/char elements that are passed to it in the order that they are passed in. e.g. `strcat('I','am','here')` would result in `'Iamhere'`. so by putting `wrapper` both before and after `original`, the `original` will be "fenced" by `wrapper`. Does this make it clearer? - I need a little more time to go through it :D ## "Getting the Outside" exercise until 13:32 - Hah, I managed to do this once I muted Enrico :D - I solved it :) but with array.. changed it more like the example **Remark: Matlab strings are not accessible by indices liek char arrays are, i.e. if you have `str = "abcde"`, and use the `outer` function on this (e.g. outer(str)), you get "abcdeabcde" as a result, because matlab considers anything to be a vector, i.e. you can always access the first (and last) element of something. In this instance with only one element present, both the first and the last element of the the "string array" `str` are "abcde", which would get concatenated** ## Exercise until xx:10 "Testing a function" scroll down in this page https://swcarpentry.github.io/matlab-novice-inflammation/07-func/index.html If you were able to solve already part 1, write it here - .I think it works fine :); input: [1, 5, 7, 90]; output: 0 0.0449 0.0674 1.0000 - I tested with z = linspace(24,156,10) and the answer was 0 0.1111 0.2222 0.3333 0.4444 0.5556 0.6667 0.7778 0.8889 1.0000 (I almost got the code right but I had to fix it with hints) - . ### Questions - What is the difference at the hints that you use L = min(min(v)) vs. just L = min(v)? - not sure, what exactly you mean. min(min()) would result in the minimum of a 2-dimensional array. The problem with min (and many other functions) is that they work on one dimension of an array. i.e. if your input is of a higher dimensionality, you don't get a single value but a vector of (in this instance) minimums of each row if you don't use min(min(x)) or min(x(:)). Does this answer your question? - Can you copy here the working functions, I think I have some error that I can't see. I would like have both plot_all_functional.m and plot_dataset.m - I will! - Ok thanks - Did you have a look at the examples from SoftwareCarpentry (i.e. the solutions they provide?) - I don't have since we did different version than in the web - They are very similar, but we will post the code here later. - I debugged the code and found the error :) I had typo in file_name vs. filename... - hurra! - from experience, if you don't make typos, then there's something wrong :D I rarely have my code to work on the first run - ^_^ - How long will be the recording active? - I will switch it off soon I mean The lectures recorded in the link? - beginning of next week they should all be on youtube. They can stay there "forever" - Excellent, thanks so much - # Final feedback What did you like about this course? - .Nice course! what about the advanced level? - . - . - . - I liked this course, it had good pace What could still be improved for future runs? - . - . - . - However, at the end there was bit hurry. - True, it was really just a small what steps make sense (i.e. looking at the documentation, putting breakpoints) See you at Matlab Advanced May 2022 :) (past year https://hackmd.io/@eglerean/MatlabAdvanced2021) --- :::info **This is the end of the document, WRITE ABOVE THIS LINE ^^** HackMD can feel slow if more than 100 participants are editing at the same time: If you do not need to write, please switch to "view mode" by clicking the eye icon on top left :eye:

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully