Da Änderungen an der Seite vorgenommen wurden, kann diese Aktion nicht abgeschlossen werden. Laden Sie die Seite neu, um sie im aktualisierten Zustand anzuzeigen.
The matrix K1 should theoretically preserve any negative values present in the mathematical result of the multiplication. Without access to the actual matrix k1 or the function used to calculate it, pinpointing the exact issue is challenging. However, you can take the following steps to identify the source of the problem:
Check ifL1is inadvertently causing the negative values to be canceled out during the multiplication. This can happen if the structure ofL1leads to such a transformation.
If the matrices are very large or contain very small values, numerical precision issues might lead to unexpected results. Try the calculation after converting all variables to high precision using vpa function. Refer to the document to know how to do this: https://www.mathworks.com/help/symbolic/vpa.html?s_tid=doc_ta#buytdfn
Print out the matrices before and after multiplication to verify where the negatives might be getting lost:
disp('k1:');
disp(k1);
disp('L1:');
disp(L1);
disp('L1 Transpose * k1:');
disp(L1.' * k1);
disp('K1:');
disp(K1);
AnalyzeL1to ensure it is not designed in a way that inherently cancels out negative values. Use MATLAB's debugging tools to step through the multiplication process and observe intermediate results.
You can see that the effect is to duplicate the upper left entries, and set the rest to zero. There is no possibility of cancelation.
However, there is the possibility of nan output if any of the inputs are infinite
k1 = zeros(4,4); k1(end,end) = inf;
K1 = L1.' * k1 * L1
K1 = 8x8
NaN NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN
However, that code duplicates the upper left corner of the matrix and sets the rest to zero. If the negatives do not happen to be in the upper left corner, then they are going to be deleted.
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.