
Comme posso generare i risultati come hyperlink?
조회 수: 1 (최근 30일)
이전 댓글 표시
Cerco di execute questo su matlab online però alla fine, il TEX e PDF non sono scaricabili. Come posso farlo che si possono scaricare via matlab online?
% Define symbolic variables
syms A B C t
% Define the matrix ρ(t)
rho_t = [0, (1/8)*(1i - 3*sqrt(7))*A*exp(-t/2), (1/8)*(1i + 3*sqrt(7))*A*exp(-t/2); ...
B*exp(-(3/4)*1i*(sqrt(7) - 1i)*t), -B*exp(-(3/4)*1i*(sqrt(7) - 1i)*t), -B*exp(-(3/4)*1i*(sqrt(7) - 1i)*t); ...
C*exp((3/4)*1i*(sqrt(7) + 1i)*t), C*exp((3/4)*1i*(sqrt(7) + 1i)*t), C*exp((3/4)*1i*(sqrt(7) + 1i)*t)];
% Simplify the matrix
rho_t = simplify(rho_t, 'Steps', 50);
% Compute eigenvalues and eigenvectors symbolically
tic
[D, P] = eig(rho_t);
D = diag(D); % Extract diagonal eigenvalues
P = simplify(P, 'Steps', 50); % Simplify eigenvectors
P_inv = inv(P);
P_inv = simplify(P_inv, 'Steps', 50);
toc
% Display results
disp('Eigenvalues (D):');
disp(D);
disp('Eigenvector matrix (P):');
disp(P);
disp('Inverse of P (P^-1):');
disp(P_inv);
% Export to LaTeX
latex_rho = latex(rho_t);
latex_D = latex(diag(D));
latex_P = latex(P);
latex_P_inv = latex(P_inv);
% Write to a .tex file
fid = fopen('diagonalization.tex', 'w');
fprintf(fid, '\\documentclass{article}\n\\usepackage{amsmath}\n\\begin{document}\n\n');
fprintf(fid, 'The matrix $\\rho(t)$ is:\n\\begin{equation}\n\\rho(t) = \\begin{pmatrix}\n%s\n\\end{pmatrix}\n\\end{equation}\n\n', latex_rho);
fprintf(fid, 'The diagonal matrix $D$ is:\n\\begin{equation}\nD = \\begin{pmatrix}\n%s\n\\end{pmatrix}\n\\end{equation}\n\n', latex_D);
fprintf(fid, 'The eigenvector matrix $P$ is:\n\\begin{equation}\nP = \\begin{pmatrix}\n%s\n\\end{pmatrix}\n\\end{equation}\n\n', latex_P);
fprintf(fid, 'The inverse of $P$ is:\n\\begin{equation}\nP^{-1} = \\begin{pmatrix}\n%s\n\\end{pmatrix}\n\\end{equation}\n\n', latex_P_inv);
fprintf(fid, '\\end{document}\n');
fclose(fid);
% Generate PDF (requires MATLAB to export figure)
figure;
text(0.1, 0.9, 'Matrix \rho(t):', 'FontSize', 12);
text(0.1, 0.8, char(rho_t), 'FontSize', 10);
text(0.1, 0.6, 'Diagonal Matrix D:', 'FontSize', 12);
text(0.1, 0.5, char(diag(D)), 'FontSize', 10);
text(0.1, 0.3, 'Eigenvector Matrix P:', 'FontSize', 12);
text(0.1, 0.2, char(P), 'FontSize', 10);
text(0.1, 0.1, 'Inverse of P (P^{-1}):', 'FontSize', 12);
text(0.1, 0.0, char(P_inv), 'FontSize', 10);
axis off;
exportgraphics(gcf, 'diagonalization.pdf', 'ContentType', 'vector');
close(gcf);
disp('LaTeX code saved to diagonalization.tex');
disp('PDF output saved to diagonalization.pdf');
Grazie
댓글 수: 0
채택된 답변
Cris LaPierre
2025년 3월 4일
편집: Cris LaPierre
2025년 3월 4일
What do you mean 'they are not downloadable'? Do you get an error when you download them? Or do you not see how to download them?
To download, find the file in your current folder browser, right-click on it, and select download.

Another option is to install MATLAB Drive Connector. This will automatically sync the contents of your MATLAB Drive to a local folder.
Note that your pdf is saving a blank image. You need to change the exportGraphics 'ContentType' option to 'image' for the text annotations to appear. Basically, the lines are too thin to be captured using the 'vector' option.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Downloads에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!