PLOTING DATA INTO GRAPHICS

1 visualizzazione (ultimi 30 giorni)
meoui
meoui il 27 Ago 2024
Modificato: DGM il 28 Ago 2024
EXECUTE THE RESULTS OF NUMBER, MATRIX, VECTOR OPERATIONS AND CONVERT THEM INTO GRAPHICS?
form book: Menke, W., 2024, Geophysical Data Analysis and Inverse Theory, Academic Press.
  3 Commenti
meoui
meoui il 27 Ago 2024
how CREATE A PRORAM BY PLOTING A DATA MATRIX, VECTOR
DGM
DGM il 28 Ago 2024
Modificato: DGM il 28 Ago 2024
There is no specific question. If you want to practice, just start practicing.
% some matrices
A = [1 0 2; 0 1 0; 2 0 1];
B = [1 0 -1; 0 2 0; 1 0 3];
C = [2 0 1; 0 3 0; 3 0 4];
% some column vectors
a = [1; 3; 5];
b = [2; 4; 6];
% basic matrix arithmetic
S = A + B
S = 3x3
2 0 1 0 3 0 3 0 4
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
D = A - B
D = 3x3
0 0 3 0 -1 0 1 0 -2
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
P = A * B
P = 3x3
3 0 5 0 2 0 3 0 1
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
% various notes from the body text
% the text emphasizes that these aren't generally equivalent
% but the book gives a poor example since A = A' in this case
Q1 = A'*B
Q1 = 3x3
3 0 5 0 2 0 3 0 1
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Q2 = A*B
Q2 = 3x3
3 0 5 0 2 0 3 0 1
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
% multiplication is not commutative
% these should differ
P1 = A*B
P1 = 3x3
3 0 5 0 2 0 3 0 1
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
P2 = B*A
P2 = 3x3
-1 0 1 0 2 0 7 0 5
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
% multiplication is associative
% these should be the same
P3 = (A*B)*C
P3 = 3x3
21 0 23 0 6 0 9 0 7
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
P4 = A*(B*C)
P4 = 3x3
21 0 23 0 6 0 9 0 7
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
% multiplication is distributive
% these should be the same
P5 = A*(B+C)
P5 = 3x3
11 0 14 0 5 0 10 0 7
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
P6 = A*B + A*C
P6 = 3x3
11 0 14 0 5 0 10 0 7
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
% the transpose of a product
% these should be the same
P7 = (A*B)'
P7 = 3x3
3 0 3 0 2 0 5 0 1
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
P8 = B'*A'
P8 = 3x3
3 0 3 0 2 0 5 0 1
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
% equivalent forms of the inner product
% these should be the same
s1 = a'*b
s1 = 44
s2 = b'*a
s2 = 44
% sum of squares (squared length)
sl = a'*a
sl = 35
% the outer product
os = a*b'
os = 3x3
2 4 6 6 12 18 10 20 30
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
% this is a literal character vector
myfilename = 'mydata.txt'
myfilename = 'mydata.txt'
% programmatically generate character vectors
k = 1;
myfilename = sprintf('myfile_%03d.txt',k) % use leading zeros
myfilename = 'myfile_001.txt'
d = 10.40;
mysentence = sprintf('distance d is %.2f football fields',d)
mysentence = 'distance d is 10.40 football fields'
% get some data from somewhere
tbl = readmatrix('TemperatureData.csv','range','C1:D32');
day = tbl(:,1);
temp = tbl(:,2);
% and make a graph
hold on
set(gca,'linewidth',2,'fontsize',12)
plot(day,temp,'r-','linewidth',2);
plot(day,temp,'ko','linewidth',2);
xlabel('Day')
ylabel('Temperature (\circ F)')
title('Temperature for January 2015')
... and so on. I'm surprised I typed that much before I got bored. I'm assuming you don't actually need dlmwrite().
If you want to go over basics, see MATLAB Onramp:
If you don't have a copy of MATLAB, you should be able to use MATLAB Online on a time-limited basis per month for free.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Environment and Settings in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by