Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Essential MATLAB Usage Techniques

Tech May 10 2
  1. Accessing the fitting toolbox using cftool

  2. Reading Excel data in MATLAB

% Store Excel file in MATLAB working directory (e.g., test.xlsx)
data = xlsread('test.xlsx');  % Import Excel data
plot(data(1,:), data(2,:));    % Plot with first row as x-data, second as y-data
  1. Understanding MATLAB bracket usage
  • Curly braces {} for cell array assignment: b{4}=[4];
  1. Plotting techniques
plot(imp(:,1), imp(:,2), 'ro');  % Red circles ('r'=red, 'o'=circle)
plot(imp(1:2,1), imp(1:2,2));   % Line between two points
% Multiple line segments
plot(imp(3:5,1), imp(3:5,2));
plot(imp(6:8,1), imp(6:8,2));
plot(imp(9:11,1), imp(9:11,2));
plot(imp(12:14,1), imp(12:14,2));
  1. Adding axis labels and titles
figure
plot(allElementPoint{1}, allElementPoint{2}, 'ro');
xlabel('x(λ)');
ylabel('y(λ)');
zlabel('z(z)');
title('XLamda YLamda Title');
  1. Dynamic text annotations
n = 12.34;
plot([0 2], [0 2]);
text(1, 1, sprintf('abcd=%0.4f', n));

% With variables
text(3, 4, sprintf('Element Count: %0.2f', element_sum));
  1. Contorlling numeric precision
format long  % High precision display
pi

format short % Standard precision
  1. Adjustnig figure size
set(gcf, 'Position', [100, 100, 350, 280], 'color', 'w');
% [x_position, y_position, width, height]
  1. Variable assignment and special characters
  • Reference MATLAB documentation for symbol usage
  1. Font customization
xlabel('u=sin\theta cos φ', 'Fontname', 'Times New Roman', 'Fontsize', figure_FontSize);
  1. Positioning axis labels
pos = axis;
xlabel('{\itu}=sin\theta cos φ', 'Fontname', 'Times New Roman',...
       'Fontsize', 'position', [pos(2) 1.15*pos(3)]);
% Bold font
'FontWeight', 'bold'

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.